import java.util.*;
import java.lang.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long[] prefix = new long[n + 1];

        for (int i = 0; i < n; i++) {

            long x = sc.nextLong();

            prefix[i + 1] = prefix[i] + x;
        }

        int q = sc.nextInt();

        while (q-- > 0) {

            int l = sc.nextInt();
            int r = sc.nextInt();

            long answer = prefix[r + 1] - prefix[l];

            System.out.println(answer);
        }

        sc.close();
	}
}