program sum1;
var
i,j,n,m,x,y:longint;
data:array[0..10000]of longint;
ss:string;
sum:array[0..10000]of int64;
procedure init;
begin
assign(input,'sum.in');
reset(input);
assign(output,'sum.out');
rewrite(output);
readln(n);
data[0]:=0;
sum[0]:=0;
for i:=1 to n do
begin
read(data[i]);
end;
readln;
end;
procedure closef;
begin
close(input);
close(output);
end;
procedure main;
var
a,b,ans:int64;
begin
readln(m);
fillchar(sum,sizeof(sum),0);
sum[1]:=data[1];
for i:=2 to n do sum[i]:=sum[i-1]+data[i];
for i:=1 to m do
begin
readln(x,y);
writeln(sum[y]-sum[x-1]);
end;
end;
begin
init;
main;
closef;
end.