#include <cstdio>
using namespace std;
FILE *fin, *fout;
const long long MAXN(10010);
long long n, m, a[MAXN], i, j, sum[MAXN];
main() {
fin = fopen("sum.in", "rb");
fout = fopen("sum.out", "wb");
fscanf(fin, "%lld", &n);
for (i = 1; i <= n; ++i) {
fscanf(fin, "%lld", &a[i]);
sum[i] = sum[i - 1] + a[i];
}
fscanf(fin, "%lld", &m);
for (long long k = 1; k <= m; ++k) {
fscanf(fin, "%lld %lld", &i, &j);
fprintf(fout, "%lld\n", sum[j] - sum[i - 1]);
}
}