// #includes {{{
#include <bits/stdc++.h>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

//{{{ Graph
typedef int Weight;
struct Edge {
	int src, dst, rev;
	Weight weight;
	Edge(int src, int dst, Weight weight=1,int rev=-1) :
		src(src), dst(dst), weight(weight), rev(rev) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
		e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
//typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

struct Graph:vector<Edges>{
	Graph(){}
	Graph(const int &n){this->assign(n,Edges());}
	//add bi-directional edge
	void addBiEdge(int from ,int to, Weight w=1){
		while(this->size()<max(from,to)+1)this->push_back(Edges());
		this->at(from).push_back(Edge(from,to,w,this->at(to).size()));
		this->at(to).push_back(Edge(to,from,w,this->at(from).size()-1));
	}
	//add directional edge
	void addEdge(int from ,int to, Weight w=1){
		while(this->size()<from+1)this->push_back(Edges());
		this->at(from).push_back(Edge(from,to,w));
	}
};
#ifdef DEBUG
#include"graph/graphviz.h"
#endif
//}}}

int N;
int A[100010];
Graph g;
int root;

Int dfs(int u=root,int p=-1){
	if(g[u].size()==1){
		return A[u];
	}
	vector<Int> a;
//	priority_queue<Int> a;
	Int s = 0;
	for(auto &e:g[u]){
		if(p==e.dst)continue;
		Int k = dfs(e.dst,u);
		if(k==-1)return -1;
		s+=k;
		a.push_back(k);
//		a.push(k);
	}
	sort(ALL(a));
	Int max_alpha = (s-s%2)/2;
	if(s<=a.back()*2)max_alpha = s-a.back();
	/*
	while(a.size()>1){
		Int x = a.top();
		a.pop();
		Int y = a.top();
		a.pop();
		max_alpha+=y;
		x-=y;
		if(x>0)a.push(x);
	}
	*/
	Int alpha = s-A[u];
	if(alpha<0 or max_alpha<alpha)return -1;
	Int ret = s-alpha*2;
	if(ret<0)return -1;
	return ret;
}

int main(){
	cin>>N;
	REP(i,N)cin>>A[i];
	if(N==2){
		if(A[0]==A[1]){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
		return 0;
	}
//	g.assign(N,Edges());
	g = Graph(N);
	REP(i,N-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g.addBiEdge(a,b);
	}
	REP(u,N){
		if(g[u].size()>1){
			root = u;
			break;
		}
	}
	Int r = dfs();
	if(r!=0){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
	}
}


Measured memory_bytes: 18304