#include <iostream>
using namespace std;
using ll=long long;
const int N=1e5+10;
ll dp[N]={0};
ll arr[N]={0};

int main()
{
    int n,m;cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        dp[i]=dp[i-1]+arr[i];
    }

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

    return 0;
}