#include<bits/stdc++.h>
using namespace std;
struct node{
int shi;
int zhong;
};
int n,m;
int shu[1000050];
int he;
node area[1000050];
int s,z;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>shu[i];
}
cin>>m;
for(int i=1;i<=m;i++){
cin>>area[i].shi>>area[i].zhong;
}
for(int i=1;i<=n;i++){
he+=shu[i];
}
for(int i=1;i<=m;i++){
s=z=0;
for(int j=1;j<area[i].shi;j++){
s+=shu[j];
}
for(int j=area[i].zhong+1;j<=n;j++){
z+=shu[j];
}
cout<<he-z-s<<endl;
}
return 0;
}