import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone
{
{
int n, m;
int[] a, summ;
Scanner in
= new Scanner
(System.
in); n = in.nextInt();
a = new int[n];
for(int i = 0; i < n; i++){
a[i] = in.nextInt();
}
summ = new int[n + 1];
summ[0] = 0;
for(int i = 1; i < n + 1; i++){
summ[i] = summ[i - 1] + a[i - 1];
}
m = in.nextInt();
for(int i = 0; i < m; i++){
int l, r;
l = in.nextInt();
r = in.nextInt();
System.
out.
println(summ
[r
] - summ
[l
- 1]); }
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uIAoJewoJCWludCBuLCBtOwoJCWludFtdIGEsIHN1bW07CgkJU2Nhbm5lciBpbiA9IG5ldyBTY2FubmVyIChTeXN0ZW0uaW4pOwoJCW4gPSBpbi5uZXh0SW50KCk7CgkJYSA9IG5ldyBpbnRbbl07CgkJZm9yKGludCBpID0gMDsgaSA8IG47IGkrKyl7CgkJCWFbaV0gPSBpbi5uZXh0SW50KCk7CgkJfQoJCXN1bW0gPSBuZXcgaW50W24gKyAxXTsKCQlzdW1tWzBdID0gMDsKCQlmb3IoaW50IGkgPSAxOyBpIDwgbiArIDE7IGkrKyl7CgkJCXN1bW1baV0gPSBzdW1tW2kgLSAxXSArIGFbaSAtIDFdOwoJCX0KCQltID0gaW4ubmV4dEludCgpOwoJCWZvcihpbnQgaSA9IDA7IGkgPCBtOyBpKyspewoJCQlpbnQgbCwgcjsKCQkJbCA9IGluLm5leHRJbnQoKTsKCQkJciA9IGluLm5leHRJbnQoKTsKCQkJU3lzdGVtLm91dC5wcmludGxuKHN1bW1bcl0gLSBzdW1tW2wgLSAxXSk7CgkJfQoJfQp9