import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main ()
{
	int n;
multitest_loop:
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto a = readln.split.map !(to !(int)).array;
		auto g = new int [] [n];
		foreach (i; 0..n - 1)
		{
			int u, v;
			readf (" %s %s", &u, &v);
			u -= 1;
			v -= 1;
			g[u] ~= v;
			g[v] ~= u;
		}
		if (n == 2)
		{
			writeln (a[0] == a[1] ? "YES" : "NO");
			continue multitest_loop;
		}
		int r = 0;
		while (g[r].length == 1)
		{
			r += 1;
		}

		long recur (int v, int p)
		{
			if (g[v].length == 1)
			{
				return a[v];
			}
			long total = 0;
			long highest = 0;
			foreach (u; g[v])
			{
				if (u == p)
				{
					continue;
				}
				long cur = recur (u, v);
				if (cur == -1)
				{
					return -1;
				}
				total += cur;
				highest = max (highest, cur);
			}
			// res * 1 + loop * 2 = total
			// res * 1 + loop * 1 = a[v]
			long loop = total - a[v];
			if (loop < 0 || loop > total - highest)
			{
				return -1;
			}
			long res = a[v] - loop;
			if (res < 0)
			{
				return -1;
			}
			return res;
		}

		writeln (recur (r, -1) == 0 ? "YES" : "NO");
	}
}
