#include <iostream>
#include <vector>
using namespace std;
using ll=long long;

int main()
{
    ll n,q;
    cin>>n>>q;
    vector<ll> arr(n+10,0);
    vector<ll> dp(n+10,0);
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        dp[i]=dp[i-1]+arr[i];
    }

    for(int i=0;i<q;i++)
    {
        ll l,r;
        cin>>l>>r;
        ll result=dp[r]-dp[l]+arr[l];
        cout<<result<<endl;
    }

    return 0;
}