#include<iostream>
#include<cstdio>
using namespace std;
int lowbit(int q)
{
return q&(-q);
}
int a[10001],b[10001]={0},c,d,e,f;
long long sum(int q)
{
if (q==lowbit(q)) return b[q];
return b[q]+sum(q-lowbit(q));
}
int main()
{
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
cin>>c;
for (int m=1;m<=c;m++)
scanf("%d",&a[m]);
for (int m=1;m<=c;m++)
for (int n=m-lowbit(m)+1;n<=m;n++)
b[m]+=a[n];
cin>>d;
for (int m=1;m<=d;m++)
{
scanf("%d%d",&e,&f);
printf("%lld\n",sum(f)-sum(e-1));
}
}