```python3 import sys input = sys.stdin.readline n, m = map(int, input().split()) arr = map(int, input().split()) prefixSum = [0] sum = 0 for i in arr: sum += i prefixSum.append(sum) for i in range(m): a, b = map(int, input().split()) print((prefixSum[b]) - prefixSum[a - 1]) ```