#include <bits/stdc++.h>
using namespace std;

struct edge{int s,t,n;}e[200010];
int n,a[100010],h[100010],d[100010];

int dfs(int x,int f)
{
	int s=0,mx=0,_=0;
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if (y!=f)  _=dfs(y,x),s+=_,mx=max(mx,_),_=1;
	if (!_)  return a[x];
	if ((s>=a[x])&&(s-a[x]<=(2*mx>s?s-mx:s/2)))
		return 2*a[x]-s;
	else  puts("NO"),exit(0);
}

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)  scanf("%d",&a[i]);
	for (int i=1,u,v,tot=0; i<n; i++)
		{
			scanf("%d %d",&u,&v),d[u]++,d[v]++;
			e[++tot]=(edge){u,v,h[u]},h[u]=tot;
			e[++tot]=(edge){v,u,h[v]},h[v]=tot;
		}
	for (int i=1; i<=n; i++)
		if (d[i]!=1)
			puts(dfs(i,0)?"NO":"YES"),exit(0);
	puts(a[1]!=a[2]?"NO":"YES");
}

int main()
{
	work();
	return 0;
}
