import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;


void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    auto edges = new int[][](N);
    foreach (_; 0..N-1) {
        auto s = readln.split.map!(to!int);
        edges[s[0] - 1] ~= s[1] - 1;
        edges[s[1] - 1] ~= s[0] - 1;
    }


    Tuple!(long, long) dfs(int n, int p) {
        if (p != -1 && edges[n].length == 1) return tuple(A[n], A[n]);

        long[] ret1, ret2;

        foreach (m; edges[n]) {
            if (m == p) continue;
            auto ret = dfs(m, n);
            if (ret[0] < 0) return ret;
            ret1 ~= ret[0];
            ret2 ~= ret[1];
        }

        long pairs = 0;
        long spare = 0;
        foreach (r; ret1) {
            auto m = min(spare, r);
            spare -= m;
            pairs += m;
            spare += r - m;
        }

        debug {writeln(n, " ", ret1, " ", ret2, " ", pairs, " ", spare, " ", A[n]);}

        if (pairs + spare > A[n]) return tuple(-1L, -1L);
        if (ret2.sum < A[n]) return tuple(-1L, -1L);

        return tuple(0L, min(A[n], ret2.sum - pairs));
    }


    auto ans = dfs(0, -1);
    writeln(ans[0] == 0 ? "YES" : "NO");
}
