#include <iostream>
#include <fstream>
#include <cstdlib>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");
int cnt_num=0;
long long int qzhuihe[100005]={0};
int cnt_cha=0;
int main(int argc, char *argv[]) {
fin>>cnt_num;
for(int x=1;x<=cnt_num;x++){
int a;
fin>>a;
qzhuihe[x]=a+qzhuihe[x-1];
}
fin>>cnt_cha;
for(int x=1;x<=cnt_cha;x++){
int ks,js;
fin>>ks>>js;
long long ans=qzhuihe[js]-qzhuihe[ks-1];
fout<<ans;
}
return 0;
}