const
maxnum=10010;
var
n,m,i,le,ri,vans:longint;
data:array[0..maxnum] of longint;
daqianzhui:array[0..maxnum] of longint;
begin
assign(input,'sum.in');
reset(input);
assign(output,'sum.out');
rewrite(output);
readln(n);
fillchar(daqianzhui,sizeof(daqianzhui),0);
for i:=1 to n do
begin
read(data[i]);
daqianzhui[i]:=daqianzhui[i-1]+data[i];
end;
readln(m);
for i:=1 to m do
begin
readln(le,ri);
vans:=0;
writeln(daqianzhui[ri]-daqianzhui[le-1]);
end;
close(input);
close(output);
end.