#include <iostream>
#include <vector>
#include <cstdint>
#include <cstddef>
#include <numeric>

using usize = std::size_t;
using i64 = std::int64_t;

struct with_sum {
    std::vector<i64> w;
    std::vector<usize> p;

    with_sum(std::vector<i64> w_): w(w_), p(w_.size()) {
        std::iota(p.begin(), p.end(), 0);
    }

    usize find(usize x) {
        if (p[x] == x) {
            return x;
        } else {
            return p[x] = find(p[x]);
        }
    }

    void unite(usize x, usize y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return;
        }
        p[y] = x;
        w[x] += w[y];
    }
};

int main() {

    usize n, m;
    std::cin >> n >> m;
    std::vector<i64> b(n + 1, 0);
    for (usize i = 0; i != n; i += 1) {
        i64 t;
        std::cin >> t;
        b[i] += t;
        b[i + 1] += t;
    }

    for (usize i = 0; i < n + 1; i += 2) {
        b[i] = -b[i];
    }

    with_sum uf(b);

    for (usize i = 0; i != m; i += 1) {
        usize l, r;
        std::cin >> l >> r;
        l -= 1;
        uf.unite(l, r);
    }

    for (usize i = 0; i != n + 1; i += 1) {
        if(uf.w[uf.find(i)] != 0) {
            std::cout << "NO\n";
            return 0;
        }
    }

    std::cout << "YES\n";
    return 0;
}