import java.util.Scanner;
import java.util.*;
class Main {
public static void main(String[] args) {
final int N = 100010;
Scanner input = new Scanner(System.in);
// code here
int n = input.nextInt();
int[] arr = new int[N];
int[] s = new int[N];
for (int i = 1; i <= n; i++) {
arr[i] = input.nextInt();
s[i] = s[i-1] + arr[i];
}
int q = input.nextInt();
for (int i = 1; i <= q; i++) {
int l = input.nextInt();
int r = input.nextInt();
System.out.println(s[r] - s[l-1]);
}
input.close();
}
}
一眼模板题,直接算出前缀和求序列