#include<bits/stdc++.h>
using namespace std;
int main(){
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
long long f[10001],m,d[10001][3],n,a[10001],s[10001]={};
cin>>n;
for (long long i=1;i<=n;i++){
cin>>a[i];
s[i]=s[i-1]+a[i];
}
cin>>m;
for(long long i=1;i<=m;i++){
for(long long j=1;j<=2;j++){
cin>>d[i][j];
}
f[i]=s[d[i][2]]-s[d[i][1]-1];cout<<f[i]<<endl;
}
//for(long long i=1;i<=m;i++){
//}
return 0;
}