const
maxnum=10000;
var
n,m,i,vx,vy:longint;
datree,data:array[0..maxnum] of longint;
function hslowbit(x:longint):longint;
begin
exit(x and (-x));
end;
procedure gcjs(x,xx:longint);
begin
while (x<=n) do
begin
datree[x]:=datree[x]+xx;
x:=x+hslowbit(x);
end;
end;
function hsqiuhe(x:longint):longint;
var
pans:longint;
begin
pans:=0;
while (x>0) do
begin
inc(pans,datree[x]);
x:=x-hslowbit(x)
end;
hsqiuhe:=pans;
end;
procedure gcshuchu(st,en:longint);
begin
writeln(hsqiuhe(en)-hsqiuhe(st-1));
end;
begin
assign(input,'sum.in');
reset(input);
assign(output,'sum.out');
rewrite(output);
readln(n);
for i:=1 to n do
read(data[i]);
fillchar(datree,sizeof(datree),0);
for i:=1 to n do
gcjs(i,data[i]);
readln(m);
for i:=1 to m do
begin
readln(vx,vy);
gcshuchu(vx,vy);
end;
close(input);
close(output);
end.