#include <iostream>
using namespace std;
const int N = 100010;
int n, m, l, r;
int q[N], s[N];
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i ++ ) scanf("%d", &q[i]);
s[0] = 0;
for (int i = 1; i <= n; i ++ ) s[i] = s[i - 1] + q[i];
for (int i = 0; i < m; i ++ ) {
cin >> l >> r;
cout << s[r] - s[l - 1] << endl;
}
}