#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdio>
using namespace std;
long long a[10005],b[10005];
int n,m,k,l;
int main()
{
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++)
scanf("%d",&a[i]);
for (int i=1;i<=n;i++)
b[i]=b[i-1]+a[i];
scanf("%d",&m);
for (int i=1;i<=m;i++)
{
scanf("%d%d",&k,&l);
printf("%lld\n",b[l]-b[k-1]);
}
//while(1);
return 0;
}