import sys input=sys.stdin.readline def main2(n,m,b_,lr): from heapq import heappop,heappush b=[x*(-1)**i for i,x in enumerate(b_)] lr.sort(key=lambda x:x[0]) ary=[0]*(n+1) now=0 for i in range(n): now-=ary[i] stc=[] mir=n d=0 while lr and lr[0][0]-1==i: l,r=heappop(lr) stc.append(r) mir=min(mir,r) d=b[i]-now ary[mir]+=d for r in stc: if r==mir:continue heappush(lr,[mir+1,r]) now+=d if b[i]==now: pass else: return False return True 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)] ret2=main2(n,m,b,lr) print('YES' if ret2 else 'NO')