import java.util.Scanner;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), q = in.nextInt();
        int i = 1;
        long []a = new long[n + 1];//使用long,因为前缀和的数据范围较大
        while (i <= n) {
            long temp = in.nextLong();
            a[i] = temp + a[i++ -1]; //执行顺序是从左到右
        }

        i = 1;
        while (i++ <= q) {
            int l = in.nextInt(), r = in.nextInt();
            System.out.println(a[r] - a[l - 1]);
        }
    }
}