#include <iostream>
#include <vector>
using namespace std;
int main(){
int n, m, t, a, b;
cin >> n >> m;
vector <int> f(n + 1, 0);
for(int i = 1; i <= n; ++i){
cin >> t;
f[i] = f[i - 1] + t;
}
while(m--){
cin >> a >> b;
cout << f[b] - f[a - 1] << endl;
}
return 0;
}