n, q = map(int, input().split()) # 错开a[0]这个位置 a = [0] a.extend(list(map(int, input().split()))) b = a.copy() # 构造前缀和数列 for i in range(1, n+1): b[i] = b[i-1] + a[i] for _ in range(0, q): l, r = map(int, input().split()) print(b[r]-b[l-1])