#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
void query_hi(int n, int m, const vector<int>& array, const vector<pair<int, int>>& queries) {
vector<long long> prefix(n + 1, 0);
for (int i = 1; i <= n; ++i) {
prefix[i] = prefix[i - 1] + array[i - 1];
}
for (const auto& query : queries) {
int i = query.first;
int j = query.second;
printf("%lld\n", prefix[j] - prefix[i - 1]);
}
}
int main() {
int n, m;
scanf("%d %d", &n, &m);
vector<int> array(n);
for (int i = 0; i < n; ++i) {
scanf("%d", &array[i]);
}
vector<pair<int, int>> queries(m);
for (int i = 0; i < m; ++i) {
scanf("%d %d", &queries[i].first, &queries[i].second);
}
query_hi(n, m, array, queries);
return 0;
}