#include<bits/stdc++.h>
using namespace std;
int a[100005], s[100005];
int main()
{
int n,m ;
cin>> n >> m;
for(int i=1; i<=n; i++)
{
cin>>a[i];
s[i] = s[i-1] + a[i]; //把前i项和求出来
}
while(m-->0){
int l,r,sum;
cin>> l >> r;
cout << s[r] - s[l-1] << endl;
}