import sys
from collections import deque

def main():
    input = sys.stdin.read().split()
    ptr = 0
    N = int(input[ptr])
    ptr += 1
    M = int(input[ptr])
    ptr += 1
    
    B = list(map(int, input[ptr:ptr + N]))
    ptr += N
    
    intervals = []
    for _ in range(M):
        L = int(input[ptr])
        R = int(input[ptr+1])
        intervals.append((L, R))
        ptr += 2
    
    # Compute t array
    t = [0] * (N + 2)  # t[0..N+1], but j ranges from 1 to N
    for j in range(1, N + 1):
        t[j] = B[j - 1] * ((-1) ** j)
    
    # Compute delta array
    delta = [0] * (N + 2)  # delta[1..N+1]
    for j in range(1, N + 1):
        delta[j] = t[j] - t[j - 1]
    delta[N + 1] = 0 - t[N]
    
    # Build adjacency list
    adj = [[] for _ in range(N + 2)]  # nodes 1..N+1
    for L, R in intervals:
        u = L
        v = R + 1
        adj[u].append(v)
        adj[v].append(u)
    
    visited = [False] * (N + 2)
    sum_ok = True
    
    for j in range(1, N + 2):
        if not visited[j]:
            q = deque()
            q.append(j)
            visited[j] = True
            total = 0
            while q:
                node = q.popleft()
                total += delta[node]
                for neighbor in adj[node]:
                    if not visited[neighbor]:
                        visited[neighbor] = True
                        q.append(neighbor)
            if total != 0:
                sum_ok = False
                break
    
    print("YES" if sum_ok else "NO")

if __name__ == "__main__":
    main()