#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m;
cin >> n >> m;
int arr[100001];
int begind;
int last;
for (int i = 1;i < n+1;i++ ) {
int tmp;
cin >> tmp;
arr[i] = arr[i-1] + tmp;
}
for (int i = 0;i < m;i++) {
cin >> begind >> last;
cout << arr[last] - arr[begind-1] << "\n";
} return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: