/*
solution:
*/
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long INT64;
const int INF=0x7fffffff;
const int MAXN=10001;
int N,M;
INT64 Sum[MAXN]={0};
int Max(int a, int b){return a>b ? a : b;}
int Min(int a, int b){return a<b ? a : b;}
int main()
{
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
scanf("%d",&N);
for(int i=1;i<=N;i++)scanf("%lld",&Sum[i]),Sum[i]+=Sum[i-1];
scanf("%d",&M);
int x,y;
for(int i=1;i<=M;i++){
scanf("%d%d",&x,&y);
printf("%lld\n",Sum[y]-Sum[x-1]);
}
fclose(stdin);
fclose(stdout);
return 0;
}