#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 5;
int n, arr[N], c[N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin >> n;
for(int i = 0; i < n; i++)
cin >> arr[i];
c[0] = arr[0];
for(int i = 1; i < n; i++)
c[i] = arr[i] + c[i - 1];
int q;
cin >> q;
for(int i = 0; i < q; i++){
int l, r;
cin >> l >> r;
l--;
r--;
int ans;
if(l > 0)
ans = c[r] - c[l - 1];
else
ans = c[r];
cout << ans << endl;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBOID0gMTAwICsgNTsKCmludCBuLCBhcnJbTl0sIGNbTl07CgppbnQgbWFpbigpewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCksY291dC50aWUoMCk7CgogICAgY2luID4+IG47CgogICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykKICAgICAgICBjaW4gPj4gYXJyW2ldOwoKICAgIGNbMF0gPSBhcnJbMF07CgogICAgZm9yKGludCBpID0gMTsgaSA8IG47IGkrKykKICAgICAgICBjW2ldID0gYXJyW2ldICsgY1tpIC0gMV07CgogICAgaW50IHE7CiAgICBjaW4gPj4gcTsKCiAgICBmb3IoaW50IGkgPSAwOyBpIDwgcTsgaSsrKXsKICAgICAgICBpbnQgbCwgcjsKCiAgICAgICAgY2luID4+IGwgPj4gcjsKICAgICAgICBsLS07CiAgICAgICAgci0tOwoKICAgICAgICBpbnQgYW5zOwogICAgICAgIGlmKGwgPiAwKQogICAgICAgICAgICBhbnMgPSBjW3JdIC0gY1tsIC0gMV07CiAgICAgICAgZWxzZQogICAgICAgICAgICBhbnMgPSBjW3JdOwoKICAgICAgICBjb3V0IDw8IGFucyA8PCBlbmRsOwogICAgfQp9