program aa;
var
a,b,c,d,e,i,j,m,n,max:longint;
l:array[1..10000]of longint;
sum:array[0..10000] of int64;
f1,f2:text;
begin
assign(f1,'sum.in');
assign(f2,'sum.out');
reset(f1);
rewrite(f2);
readln(f1,n);
sum[1]:=0;
for i:=1 to n do
begin
read(f1,l[i]);
sum[i]:=sum[i-1]+l[i];
end;
readln(f1);
readln(f1,m);
for i:=1 to m do
begin
readln(f1,a,b);
writeln(f2,sum[b]-sum[a-1]);
end;
close(f1);close(f2);
end.