#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
int arr[N] = {0};
int n,m;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >> n >> m;
for(int i = 1;i <= n;i++){
int num; cin >> num;
arr[i] = num + arr[i-1];
}
while(m--){
int l,r; cin >> l >> r;
cout << arr[r]-arr[l-1] << endl;
}
return 0;
}