n, q = map(int,input().split())
a = list(map(int,input().split()))

ans, dp = 0, []
for c in a:#制造前缀和列表
    ans += c
    dp.append(ans)

for _ in range(q):#输出区间前缀和
    l, r = map(int,input().split())
    if l==1:
        print(dp[r-1])
    else:
        print(dp[r-1]-dp[l-2])