#include<iostream>
#include<vector>
#include<string>
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;
const int MAX_N=1e5+5;
ll A[MAX_N];
vector<int>G[MAX_N];
ll T[MAX_N];
ll max(ll a,ll b){
	if(a>b)return a;
	else return b;
}
ll min(ll a,ll b){return -1*max(-a,-b);}
bool dfs(int v,int prev){
	if(G[v].size()==1 &&G[v][0]==prev){
		T[v]=A[v];
		return true;
	}
	bool re=true;
	ll sum=0;
	ll ma=0;
	rep(i,G[v].size()){
		if(G[v][i]!=prev){
			if(!dfs(G[v][i],v))return false;
			sum+=T[G[v][i]];
			ma=max(ma,T[G[v][i]]);
		}
	}
	T[v]=2*A[v]-sum;
	re&=(sum>=T[v]);
	re&=(T[v]>=0);
	re&=((min(sum-ma,sum/2)>=((sum-T[v])/2)));
	return re;
}
int main(){
	int n;
	cin>>n;
	rep(i,n)cin>>A[i+1];
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if(dfs(1,0) &&(G[1].size()==1||T[1]==0))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}
