#include <iostream>
using namespace std;
const int N = 100010;
int n, m;
int q[N], s[N]; // s[0] 初始化为 0 ; 为后续的s[i] = s[i - 1] + q[i] 做准备
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i ++ ) scanf("%d", &q[i]), s[i] = s[i - 1] + q[i];//读入数组,并初始化前缀和数组
//算前缀和数组,或者差分数组,从下标1开始更加省事优雅。记得初始化好前缀和s[0] = 0。
//从0开始需要特判s[0] = q[0]
while (m -- )
{
int l, r;
scanf("%d%d", &l, &r);
printf("%d\n", s[r] - s[l - 1]);
}
return 0;
}