#include <iostream>
using namespace std;
int main()
{
int n , q;
cin >>n>>q;
int arr[n];
for(int i=0 ; i<n;i++) cin>>arr[i];
int pfxsum[n]={};
int summ=0;
for (int i=0;i<n;i++){
summ +=arr[i];
pfxsum[i]=summ;
}
for(int k=0;k<q;k++){
int l,r;cin>>l>>r;
l--,r--;
long long sum =0;
if (l == 0)
sum = pfxsum[r];
else
sum = pfxsum[r] - pfxsum[l - 1];
cout<<sum<<endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKewoKCmludCBuICwgcTsKY2luID4+bj4+cTsKaW50IGFycltuXTsKZm9yKGludCBpPTAgOyBpPG47aSsrKSBjaW4+PmFycltpXTsKaW50IHBmeHN1bVtuXT17fTsKaW50IHN1bW09MDsKZm9yIChpbnQgaT0wO2k8bjtpKyspewpzdW1tICs9YXJyW2ldOwpwZnhzdW1baV09c3VtbTsKfQoKZm9yKGludCBrPTA7azxxO2srKyl7CmludCBsLHI7Y2luPj5sPj5yOwpsLS0sci0tOwpsb25nIGxvbmcgc3VtID0wOwogIGlmIChsID09IDApIAogICAgICAgICAgICBzdW0gPSBwZnhzdW1bcl07CiAgICAgICAgZWxzZQogICAgICAgICAgICBzdW0gPSBwZnhzdW1bcl0gLSBwZnhzdW1bbCAtIDFdOwoKY291dDw8c3VtPDxlbmRsOwp9CnJldHVybiAwOwoKCn0=