import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        long[] preSum = new long[n + 1];
        Arrays.setAll(preSum, k -> k == 0 ? 0 : preSum[k - 1] + sc.nextInt());
        while (q-- > 0) {
            System.out.println(-preSum[sc.nextInt() - 1] + preSum[sc.nextInt()]);
        }
    }
}