program cogs36;
var
a:array[1..10000]of longint;
s:array[0..10000]of int64;
i,j,n,m,p,q:longint;
procedure init;
begin
assign(input,'sum.in');reset(input);
assign(output,'sum.out');rewrite(output);
end;
procedure main;
begin
readln(n);
for i:=1 to n do
begin
read(a[i]);
s[i]:=s[i-1]+a[i];
end;
readln(m);
for i:=1 to m do
begin
readln(p,q);
writeln(s[q]-s[p]+a[p]);
end;
end;
begin
init;
main;
close(output);
end.//complete bychouyi20140910