#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int n;
cin>>n;
vector<int> nums(n);
for(int i=0;i<n;i++){
int e;
cin>>e;
nums[i]=e;
}
for(int i=1;i<n;i++){
nums[i]=nums[i-1]+nums[i];
}
int q;
cin>>q;
while(q--){
int i,j;
cin>>i>>j;
cout<<nums[j]-nums[i-1]<<endl;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCWludCBuOwoJY2luPj5uOwoJdmVjdG9yPGludD4gbnVtcyhuKTsKCWZvcihpbnQgaT0wO2k8bjtpKyspewoJCWludCBlOwoJCWNpbj4+ZTsKCQludW1zW2ldPWU7Cgl9Cglmb3IoaW50IGk9MTtpPG47aSsrKXsKCQludW1zW2ldPW51bXNbaS0xXStudW1zW2ldOwoJfQoJaW50IHE7CgljaW4+PnE7Cgl3aGlsZShxLS0pewoJCWludCBpLGo7CgkJY2luPj5pPj5qOwoJCWNvdXQ8PG51bXNbal0tbnVtc1tpLTFdPDxlbmRsOwoJfQoJCn0=