#include <iostream>
#include <vector>
using namespace std;
long long get_sum(long long sums[], long long start, long long end) {
if (start == 0) return sums[end];
return sums[end] - sums[start - 1];
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); // вперед_славяне
long long n, q;
long long a[100000], sums[100000];
cin >> n;
cin >> q;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sums[0] = a[0];
for (int i = 1; i < n; i++) {
sums[i] = sums[i - 1] + a[i];
}
for (int i = 0; i < q; i++) {
int x, y;
cin >> x >> y;
cout << get_sum(sums, x - 1, y - 1) << "\n";
}
return 0;
}