import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
int n = in.nextInt(),q = in.nextInt();
int[] arr = new int[n+1];
for(int i = 1; i < n+1; i++){
arr[i] = in.nextInt();
}
long[] dp = new long[n+1];
for(int i = 1; i < n+1; i++){
dp[i] = dp[i-1] + arr[i];
}
while(q > 0){
int l = in.nextInt(), r = in.nextInt();
System.out.println(dp[r] - dp[l-1]);
q--;
}
// while (in.hasNextInt()) { // 注意 while 处理多个 case
// int a = in.nextInt();
// int b = in.nextInt();
// System.out.println(a + b);
// }
}
}
class Solution {
public int[] productExceptSelf(int[] nums) {
int l = nums.length;
int[] f = new int[l];
int[] g = new int[l];
f[0] = 1;
g[l-1] = 1;
for(int i = 1; i < l; i++){
f[i] = f[i-1]*nums[i-1];
}
for(int i = l-2; i >= 0; i--){
g[i] = g[i+1]*nums[i+1];
}
int[] answer = new int[l];
for(int i = 0; i < l; i++){
answer[i] = f[i]*g[i];
}
return answer;
}
}