#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
int n;
int a[100000],s[1000000];
signed main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int n, m;
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i];
cin >> m;
while(m--)
{
int x, y;
cin >> x >> y;
for(int i = x; i <= y; i++)
s[i] = s[i - 1] + a[i];
cout << s[y] << "\n";
for(int i = x; i <= y; i++) s[i] = 0;
}
return 0;
}