mod = 1000000007 eps = 10**-9 def main(): import sys from collections import deque input = sys.stdin.buffer.readline N, M = map(int, input().split()) B = list(map(int, input().split())) B = [b * (-1)**i for i, b in enumerate(B)] C = [0] * (N+1) C[0] = B[0] for i in range(1, N): C[i] = B[i] - B[i-1] C[N] = -B[-1] adj = [[] for _ in range(N + 1)] for _ in range(M): l, r = map(int, input().split()) l -= 1 r -= 1 adj[l].append(r+1) adj[r+1].append(l) seen = [0] * (N+1) par = [-1] * (N+1) dp = [0] * (N+1) for v0 in range(N+1): if seen[v0]: continue que = deque() que.append(v0) seen[v0] = 1 seq = [] while que: v = que.popleft() seq.append(v) for u in adj[v]: if not seen[u]: par[u] = v que.append(u) seq.reverse() for v in seq: if v != v0: x = C[v] - dp[v] dp[v] += x dp[par[v]] -= x else: if dp[v] != C[v]: print("NO") exit() print("YES") if __name__ == '__main__': main()