program cogs36;
const
maxn=10000;
var
l,r,i,j,n,m,x:longint;
sum:array[0..maxn] of int64;
begin
assign(input,'sum.in'); reset(input);
assign(output,'sum.out'); rewrite(output);
readln(n);
fillchar(sum,sizeof(sum),0);
for i:=1 to n do
begin
read(x);
sum[i]:=sum[i-1]+x;
end;
readln(m);
for i:=1 to m do
begin
readln(l,r);
writeln(sum[r]-sum[l-1]);
end;
close(input); close(output);
end.