import sys input = sys.stdin.readline sys.setrecursionlimit(2*10**5) 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(v): global tmp for nv in edge[v]: if not used[nv]: used[nv] = True if nv!=N: tmp += B[nv] dfs(nv) for i in range(N): tmp = 0 check = used[-1] if not used[i]: used[i] = True tmp += B[i] dfs(i) check2 = used[-1] if not check and check2: continue else: if tmp!=0: exit(print("NO")) print("YES")