前缀和真是个好东西
#include <iostream>
#include <cstring>
#include <algorithm>
const int N = 1e5+10;
using namespace std;
int n,m[N],k,s[N],t[N],l,r;
int main()
{
cin>>n>>k;
for (int i = 1; i <= n; i ++ )
cin>>m[i],s[i]=m[i]+s[i-1];
for (int i = 0; i < k; i ++ )
{
cin>>l>>r;
cout<<s[r]-s[l-1]<<endl;
}
return 0;
}