#include<cstdio>
using namespace std;
#define LL long long
#define N 10010
LL s[N];
int n,m;
int main(){
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
scanf("%d",&n);
s[0] = 0;
for (int i = 1 ; i <= n; i ++){
scanf("%lld",&s[i]);
s[i] += s[i - 1];
}
scanf("%d",&m);
int l,r;
while (m --){
scanf("%d %d",&l,&r);
if (l == 0 && l == r) puts("0");
else printf("%lld\n",s[r] - s[l - 1]);
}
return 0;
}