import sys input = sys.stdin.readline N,M = map(int,input().split()) B = list(map(int,input().split())) for i in range(1,N,2): B[i] = -B[i] for i in range(N-1,0,-1): B[i] -= B[i-1] edge = [[] for i in range(N+1)] for _ in range(M): l,r = map(int,input().split()) edge[r].append(l-1) edge[l-1].append(r) used = [False]*(N+1) tmp = 0 def dfs(s): tmp = 0 used[s] = True tmp += B[s] stack = [s] while stack: v = stack.pop() for nv in edge[v]: if not used[nv]: used[nv] = True if nv!=N: tmp += B[nv] stack.append(nv) return tmp for i in range(N): check = used[-1] if not used[i]: tmp = dfs(i) check2 = used[-1] if not check and check2: continue else: if tmp!=0: exit(print("NO")) print("YES")