#include<iostream>
#include<cstdio>
using namespace std;
int n,x;
long long a[100010];
long long bk[10010][10010];
int v,m,b;
int cgy(){
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++){
cin>>x;
a[i]=a[i-1]+x;
}
cin>>v;
for(int i=1;i<=v;i++){
cin>>m>>b;
if(bk[m][b]){
cout<<bk[m][b]<<endl;
}
cout<<a[b+1]-a[m]<<endl;
bk[m][b]=a[b+1]-a[m];
}
return 0;
}
int clz=cgy();
int main(){;}