import java.util.; import java.io.; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = null; while((str = in.readLine()) != null){ String[] arr = str.split(" "); int n = Integer.parseInt(arr[0]); int q = Integer.parseInt(arr[1]); String[] res = in.readLine().split(" "); long[] dest = new long[n+1]; long sum = 0; for(int i = 0;i < n;i++){ sum += Integer.parseInt(res[i]); dest[i+1] = sum; } for(int i = 0;i < q;i ++){ String[] temp = in.readLine().split(" "); int l = Integer.parseInt(temp[0]); int r = Integer.parseInt(temp[1]); System.out.println(dest[r] - dest[l-1]); } } } }