#include<bits/stdc++.h>
using namespace std;
#define el "\n"
#define ll long long
#define ull unsigned long long
#define se second
#define fi first
#define be begin()
#define en end()
#define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
int main()
{
Faster;
int n; cin >> n;
ll a[n + 1];
a[0] = 0;
for(int i = 1; i <= n; i++)
{
cin >> a[i];
a[i] = a[i] + a[i-1];
}
int q; cin >> q;
while(q--)
{
int i, j;
cin >> i >> j;
cout << a[j + 1] - a[i] << el;
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBlbCAiXG4iCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgdWxsIHVuc2lnbmVkIGxvbmcgbG9uZwojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgYmUgYmVnaW4oKQojZGVmaW5lIGVuIGVuZCgpCiNkZWZpbmUgRmFzdGVyIGNpbi50aWUoMCk7IGNvdXQudGllKDApOyBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwppbnQgbWFpbigpCnsKICAgIEZhc3RlcjsKICAgIGludCBuOyBjaW4gPj4gbjsKICAgIGxsIGFbbiArIDFdOwogICAgYVswXSA9IDA7CiAgICBmb3IoaW50IGkgPSAxOyBpIDw9IG47IGkrKykKICAgIHsKICAgICAgICBjaW4gPj4gYVtpXTsKICAgICAgICBhW2ldID0gYVtpXSArIGFbaS0xXTsKICAgIH0KICAgIGludCBxOyBjaW4gPj4gcTsKICAgIHdoaWxlKHEtLSkKICAgIHsKICAgICAgICBpbnQgaSwgajsKICAgICAgICBjaW4gPj4gaSA+PiBqOwogICAgICAgIGNvdXQgPDwgYVtqICsgMV0gLSBhW2ldIDw8IGVsOwogICAgfQoKfQo=