실버3 문제
import sys
n, m = map(int, sys.stdin.readline().rstrip().split())
arr = list(map(int, sys.stdin.readline().rstrip().split()))
answer = [0]
ssum = 0
for i in arr:
ssum = ssum + i
answer.append(ssum)
for _ in range(m):
a, b = map(int, sys.stdin.readline().rstrip().split())
hap = answer[b] - answer[a-1]
print(hap)