#include <iostream> #include <vector> using namespace std; int main() { int n, q; cin >> n >> q; vector<int> arr1(n); //n个整数 for(int i = 0; i < n; ++i) cin >> arr1[i]; //记录前n项和的数组 vector<long long> arr2(n + 1, 0); for(int i = 0; i < n; ++i) arr2[i + 1] = arr2[i] + arr1[i]; while(q--) { int l,r; cin >> l >> r; cout << arr2[r] - arr2[l - 1] << endl; } return 0; }