def main1(n,m,b,lr): b=[x*(-1)**i for i,x in enumerate(b)] rary=[set() for _ in range(n)] for l,r in lr:rary[l-1].add(r) ary=[0]*(n+1) now=0 for i in range(n): now-=ary[i] stc=set() d=0 while rary[i]: r=rary[i].pop() stc.add(r) d=b[i]-now if stc: stc=list(stc) stc.sort() for x,y in zip(stc[0:],stc[1:]): rary[x].add(y) ary[stc[0]]+=d now+=d if b[i]==now: pass else: return False return True import sys input=sys.stdin.readline if __name__=='__main__': n,m=map(int,input().split()) b=list(map(int,input().split())) lr=[list(map(int,input().split())) for _ in range(m)] ret1=main1(n,m,b,lr) print('YES' if ret1 else 'NO')