import sys input = sys.stdin.readline N,M=map(int,input().split()) A=list(map(int,input().split())) PE=[tuple(map(int,input().split())) for i in range(M)] P=[0]*(N+1) for x,w in PE: P[x]+=w for i in range(N): if A[i]
1:
mid=(OK+NG)//2
P=[0]*(N+2)
R=[0]*(N+2)
L=[0]*(N+2)
RR=[0]*(N+2)
LL=[0]*(N+2)
for x,w in PE:
if mid!=0:
h=w//mid
else:
h=10**9
P[max(1,x-h)]+=w
if x+h+1