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() mir=n d=0 for r in rary[i]: stc.add(r) mir=min(mir,r) d=b[i]-now ary[mir]+=d for r in stc: if r==mir:continue rary[mir].add(r) 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')