var
n,l,r:integer;
i,m:longint;
a:array[-1..10000] of int64;
begin
assign(input,'sum.in');
assign(output,'sum.out');
reset(input);
rewrite(output);
//while not(eof) do
//begin
readln(n);
a[0]:=0;
for i:=1 to n do
begin
read(a[i]);
inc(a[i],a[i-1]);
end;
readln(m);
for i:=1 to m do
begin
readln(l,r);
writeln(a[r]-a[l-1]);
end;
//end;
close(input);
close(output);
end.