#include <iostream>
using namespace std;
int main() {
int n,m;
cin>>n>>m;
int a[n+1];
long long pr[n+2]={0,};
for(int i=1; i<=n; i++)
cin>>a[i];
for(int i=1; i<=n; i++)
pr[i]=pr[i-1]+a[i];
for(int i=1; i<=n; i++){
int x,y;
cin>>x>>y;
cout<<pr[y]+pr[x-1]<<endl;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbWFpbigpIHsKCWludCBuLG07CgljaW4+Pm4+Pm07CglpbnQgYVtuKzFdOwoJbG9uZyBsb25nIHByW24rMl09ezAsfTsKCWZvcihpbnQgaT0xOyBpPD1uOyBpKyspCgkJY2luPj5hW2ldOwoJZm9yKGludCBpPTE7IGk8PW47IGkrKykKCQlwcltpXT1wcltpLTFdK2FbaV07Cglmb3IoaW50IGk9MTsgaTw9bjsgaSsrKXsKCQlpbnQgeCx5OwoJCWNpbj4+eD4+eTsKCWNvdXQ8PHByW3ldK3ByW3gtMV08PGVuZGw7Cgl9Cn0=