#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	std::cin >> n;
    vector<int> a(n,0);
    n--;
    while(n--){
        int nod;
        int node;
        cin >>nod;
        cin >>node;
        a[nod-1]=a[nod-1] + 1;
        a[node-1]=a[node-1] + 1;
    }
    for(int i = 0 ; i < a.size() ; i++){
        if(a[i]==2){
            std::cout << "NO" << std::endl;

            return 0 ;
        }

    }
    std::cout << "YES" << std::endl;

	return 0;
}


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

#define deb(x) cout<<#x<<"="<<x<<endl
#define deb2(x,y) cout<<#x<<"="<<x<<", "<<#y<<"="<<y<<endl
#define deb3(x,y,z) cout<<#x<<"="<<x<<", "<<#y<<"="<<y<<", "<<#z<<"="<<z<<endl
#define rng(x) x.begin(), x.end()
#define pb push_back
#define F first
#define S second
#define el endl

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;

void solve(){
	int n; cin>>n;
	vi deg(n);
	for (int i = 0; i < n-1; ++i){
		int u, v; cin>>u>>v;
		u--; v--;
		deg[u]++; deg[v]++;
	}

	for (int i = 0; i < n; ++i){
		if(deg[i] == 2){
			cout<<"NO\n";
			return;
		}
	}
	cout<<"YES\n"; return;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int T=1, tc = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


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

#define deb(x) cout<<#x<<"="<<x<<endl
#define deb2(x,y) cout<<#x<<"="<<x<<", "<<#y<<"="<<y<<endl
#define deb3(x,y,z) cout<<#x<<"="<<x<<", "<<#y<<"="<<y<<", "<<#z<<"="<<z<<endl
#define rng(x) x.begin(), x.end()
#define pb push_back
#define F first
#define S second
#define el endl

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;

const int N = 2e5;
vi adj[N];

void solve(){
	int n; cin>>n;
	for (int i = 0; i < n-1; ++i){
		int u, v; cin>>u>>v;
		u--; v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	if(n==2){
		cout<<"YES\n";
		return;
	}
	if(n==3){
		cout<<"NO\n";
		return;
	}

	vb leaf(n);
	for (int i = 0; i < n; ++i)
		leaf[i] = (adj[i].size()==1);

	for (int i = 0; i < n; ++i){
		if(leaf[i]) continue;
		int lf = 0;
		for (int child : adj[i])
			lf += leaf[child];
		if(lf < 2){
			cout<<"NO\n";
			return;
		}
	}
	cout<<"YES\n"; return;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int T=1, tc = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


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

#define deb(x) cout<<#x<<"="<<x<<endl
#define deb2(x,y) cout<<#x<<"="<<x<<", "<<#y<<"="<<y<<endl
#define deb3(x,y,z) cout<<#x<<"="<<x<<", "<<#y<<"="<<y<<", "<<#z<<"="<<z<<endl
#define rng(x) x.begin(), x.end()
#define pb push_back
#define F first
#define S second
#define el endl

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;

const int N = 2e5;
vi adj[N];

void solve(){
	int n; cin>>n;
	for (int i = 0; i < n-1; ++i){
		int u, v; cin>>u>>v;
		u--; v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	if(n==2){
		cout<<"YES\n";
		return;
	}

	vb leaf(n);
	for (int i = 0; i < n; ++i)
		leaf[i] = (adj[i].size()==1);

	for (int i = 0; i < n; ++i){
		if(leaf[i]) continue;
		int lf = 0;
		for (int child : adj[i])
			lf += leaf[child];
		if(lf < 2){
			cout<<"NO\n";
			return;
		}
	}
	cout<<"YES\n"; return;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int T=1, tc = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > gr;
int main(){
	int n;
	int a,b;
	scanf("%d",&n);
	gr.assign(n+1,vector<int>());
	vector<int> con(n+1);
	for(int i = 1; i < n; i++){
		scanf("%d %d",&a,&b);
		gr[a].push_back(b);
		gr[b].push_back(a);
		con[a]++;
		con[b]++;
	}
	bool sw = 1;
	for(int i = 1; i <= n; i++){
		if(con[i] == 2)
			sw = 0;
	}
	if(sw)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > gr;
int main(){
	int n;
	int a,b;
	scanf("%d",&n);
	gr.assign(n+1,vector<int>());
	vector<int> con(n+1);
	for(int i = 1; i < n; i++){
		scanf("%d %d",&a,&b);
		gr[a].push_back(b);
		gr[b].push_back(a);
		con[a]++;
		con[b]++;
	}
	if(n == 2){
		printf("YES\n");
		return 0;
	}
	vector<bool> control(n+1,false);
	queue<int> pad;
	vector<int> tam(n+1);
	for(int i = 1; i <= n; i++){
		if(gr[i].size()==1){
			con[i] = 1;
			pad.push(gr[i][0]);
			tam[gr[i][0]]++;
		}
	}
	bool sw = 1;
	int u;
	while(!pad.empty()){
		u = pad.front();
		pad.pop();
		if(tam[u] == 1)
			sw = 0;
	}
	if(!sw){
		printf("NO\n");
		return 0;
	}
	for(int i = 1; i <= n; i++){
		if(!con[i]){
			bool es = 1;
			for(int v : gr[i])
				es &= con[v];
			if(!es){
				sw = 0;
				break;
			}
			if(gr[i].size()<=2){
				sw=0;
				break;
			}
		}
	}
	if(n==3)sw=0;
	if(sw)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > gr;
int main(){
	int n;
	int a,b;
	scanf("%d",&n);
	gr.assign(n+1,vector<int>());
	vector<int> con(n+1);
	for(int i = 1; i < n; i++){
		scanf("%d %d",&a,&b);
		gr[a].push_back(b);
		gr[b].push_back(a);
		con[a]++;
		con[b]++;
	}
	if(n == 2){
		printf("YES\n");
		return 0;
	}
	vector<bool> control(n+1,false);
	queue<int> pad;
	vector<int> tam(n+1);
	for(int i = 1; i <= n; i++){
		if(gr[i].size()==1){
			con[i] = 1;
			pad.push(gr[i][0]);
			tam[gr[i][0]]++;
		}
	}
	bool sw = 1;
	int u;
	while(!pad.empty()){
		u = pad.front();
		pad.pop();
		if(tam[u] == 1)
			sw = 0;
	}
	if(!sw){
		printf("NO\n");
		return 0;
	}
	for(int i = 1; i <= n; i++){
		if(!con[i]){
			bool es = 1;
			for(int v : gr[i])
				es &= con[v];
			if(!es){
				sw = 0;
				break;
			}
		}
	}
	if(n==3)sw=0;
	if(sw)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > gr;
int main(){
	int n;
	int a,b;
	scanf("%d",&n);
	gr.assign(n+1,vector<int>());
	vector<int> con(n+1);
	for(int i = 1; i < n; i++){
		scanf("%d %d",&a,&b);
		gr[a].push_back(b);
		gr[b].push_back(a);
		con[a]++;
		con[b]++;
	}
	if(n == 2){
		printf("YES\n");
		return 0;
	}
	vector<bool> control(n+1,false);
	queue<int> pad;
	vector<int> tam(n+1);
	for(int i = 1; i <= n; i++){
		if(gr[i].size()==1){
			con[i] = 1;
			pad.push(gr[i][0]);
			tam[gr[i][0]]++;
		}
	}
	bool sw = 1;
	int u;
	while(!pad.empty()){
		u = pad.front();
		pad.pop();
		if(tam[u] == 1)
			sw = 0;
	}
	if(!sw){
		printf("NO\n");
		return 0;
	}
	sw = 1;
	for(int i = 1; i <= n; i++){
		if(con[i] == 2)
			sw = 0;
	}
	if(sw)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > gr;
int main(){
	int n;
	int a,b;
	scanf("%d",&n);
	gr.assign(n+1,vector<int>());
	vector<int> con(n+1);
	for(int i = 1; i < n; i++){
		scanf("%d %d",&a,&b);
		gr[a].push_back(b);
		gr[b].push_back(a);
		con[a]++;
		con[b]++;
	}
	sw = 1;
	for(int i = 1; i <= n; i++){
		if(con[i] == 2)
			sw = 0;
	}
	if(sw)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > gr;
int main(){
	int n;
	int a,b;
	scanf("%d",&n);
	gr.assign(n+1,vector<int>());
	vector<int> con(n+1);
	for(int i = 1; i < n; i++){
		scanf("%d %d",&a,&b);
		gr[a].push_back(b);
		gr[b].push_back(a);
		con[a]++;
		con[b]++;
	}
	if(n == 2){
		printf("YES\n");
		return 0;
	}
	vector<bool> control(n+1,false);
	queue<int> pad;
	vector<int> tam(n+1);
	for(int i = 1; i <= n; i++){
		if(gr[i].size()==1){
			con[i] = 1;
			pad.push(gr[i][0]);
			tam[gr[i][0]]++;
		}
	}
	bool sw = 1;
	int u;
	while(!pad.empty()){
		u = pad.front();
		pad.pop();
		if(tam[u] == 1)
			sw = 0;
	}
	if(!sw){
		printf("NO\n");
		return 0;
	}
	sw = 1;
	for(int i = 1; i <= n; i++){
		if(tam[i] == 2)
			sw = 0;
	}
	if(sw)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define lp(n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
vector<ll> adj[100010];
bool trav[100010];
ll indeg[100010];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,a,b;
	cin>>n;
	lp(n-1){
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
		indeg[a]++,indeg[b]++;
	}
	lp(n+1)
		if(indeg[i]==2){
			cout<<"NO\n";
			return 0;
		}
	cout<<"YES\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define lp(n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
vector<ll> adj[100010];
bool trav[100010];
ll indeg[100010];
void dfs(ll n,ll sign){
	if(trav[n])
		return;
	trav[n]=1;
	if(sign==-1){
		for(auto it:adj[n])
			if(!trav[it])
				dfs(it,indeg[n]%2);
		return;
	}
	for(auto it:adj[n])
		if(!trav[it])
		{
			if(indeg[n]%2!=indeg[it]%2){
				cout<<"NO\n";
				exit(0);
			}
			dfs(it,indeg[n]%2);
		}
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,a,b;
	cin>>n;
	lp(n-1){
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
		indeg[a]++,indeg[b]++;
	}
	dfs(1,-1);
	cout<<"YES\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define lp(n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
vector<ll> adj[100010];
bool trav[100010];
ll indeg[100010];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,a,b;
	cin>>n;
	lp(n-1){
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
		indeg[a]++,indeg[b]++;
	}
	if(n%2)
	{
		cout<<"NO\n";
		return 0;
	}
	ll leaf=0;
	lp(n+1)if(indeg[i]==1)leaf++;
	leaf%2?cout<<"NO\n":cout<<"YES\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define lp(n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
vector<ll> adj[100010];
bool trav[100010];
ll leaf[100010],indeg[100010];
ll dfs(ll n){
	trav[n]=1;
	ll leaf=0;
	bool tru=0;
	for(auto it:adj[n])
		if(!trav[it])
		{
			tru=1;
			leaf+=dfs(it);
		}
	if(!tru)
		return 1;
	else
		if(leaf%2)
		{
			cout<<"NO\n";
			exit(0);
		}
	return leaf;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,a,b;
	cin>>n;
	lp(n-1){
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
		indeg[a]++,indeg[b]++;
	}
	if(n==2){
		cout<<"YES\n";
		return 0;
	}
	dfs(1);
	cout<<"YES\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define lp(n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
vector<ll> adj[100010];
bool trav[100010];
ll indeg[100010];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,a,b;
	cin>>n;
	lp(n-1){
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
		indeg[a]++,indeg[b]++;
	}
	ll leaf=0;
	lp(n+1)if(indeg[i]==1)leaf++;
	leaf%2==(n-leaf)%2?cout<<"YES\n":cout<<"NO\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define lp(n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
ll indeg[100010];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,a,b;
	cin>>n;
	lp(n-1){
		cin>>a>>b;
		indeg[a]++,indeg[b]++;
	}
	lp(n+1)
		if(indeg[i]==2){
			cout<<"NO\n";
			return 0;
		}
	cout<<"YES\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define lp(n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
vector<ll> adj[100010];
bool trav[100010];
ll leaf[100010],indeg[100010];
void dfs(ll n){
	if(trav[n])
		return;
	trav[n]=1;
	for(auto it:adj[n])
		if(!trav[it])
		{
			if(leaf[n]%2!=leaf[it]%2){
				cout<<n<<"-"<<it<<"\n";
				cout<<"NO\n";
				exit(0);
			}
			dfs(it);
		}
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,a,b;
	cin>>n;
	lp(n-1){
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
		indeg[a]++,indeg[b]++;
	}
	n%2?cout<<"NO\n":cout<<"YES\n";
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxm pow(2,32)-1
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define sz(x) (ll)x.size()

using namespace std;

int main()
{
ios
	ll n,Tests=1,c=0,i=0,j=0;
	cin>>Tests;
	n=Tests;
	int a[Tests]={0};
	while(--Tests)
	{
		cin>>i>>j;
		a[i]++;
		a[j]++;
	}
	for(i=0;i<=n;i++)
	{
		if(a[i]==2)
		{
			c=1;
			break;
		}
	}

	if(c) cout<<"NO";
	else cout<<"YES";

	return 0;
}

/*

*/


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxm pow(2,32)-1
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define sz(x) (ll)x.size()

using namespace std;

int main()
{
ios
	ll n,Tests=1,c=0,i=0,j=0;
	cin>>Tests;
	n=Tests;
	int a[Tests+1]={0};
	while(--Tests)
	{
		cin>>i>>j;
		a[i]++;
		a[j]++;
	}
	for(i=0;i<=n;i++)
	{
		if(a[i]==2)
		{
			c=1;
			break;
		}
	}

	if(c) cout<<"NO";
	else cout<<"YES";

	return 0;
}

/*

*/


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxm pow(2,32)-1
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define sz(x) (ll)x.size()

using namespace std;

int main()
{
ios
	ll n,Tests=1,c=0,i=0,j=0;
	cin>>Tests;
	n=Tests;
	int a[Tests]={0};
	while(--Tests)
	{
		cin>>i>>j;
		a[i]++;
		a[j]++;
	}
	for(i=0;i<=n;i++)
	{
		if(a[i]%2==0 && a[i]!=0)
		{
			c=1;
			break;
		}
	}
	j=0;
	for(i=0;i<=n;i++)
	{
		if(a[i]==1)
		j++;
	}
	if(j==n-1) c=0;

	if(c) cout<<"NO";
	else cout<<"YES";

	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxm pow(2,32)-1
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define sz(x) (ll)x.size()

using namespace std;

int main()
{
ios
	ll n,Tests=1,c=0,i=0,j=0;
	cin>>Tests;
	n=Tests;
	int a[Tests]={0};
	while(--Tests)
	{
		cin>>i>>j;
		a[i]++;
		a[j]++;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]%2==0 && a[i]!=0)
		{
			c=1;
			break;
		}
	}

	if(c) cout<<"NO";
	else cout<<"YES";

	return 0;
}

/*

*/


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxm pow(2,32)-1
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define sz(x) (ll)x.size()

using namespace std;

int main()
{
ios
	ll n,Tests=1,c=0,i=0,j=0;
	cin>>Tests;
	n=Tests;
	int a[Tests]={0};
	while(--Tests)
	{
		cin>>i>>j;
		a[i]++;
		a[j]++;
	}
	for(i=0;i<=n;i++)
	{
		if(a[i]%2==0 && a[i]!=0)
		{
			c=1;
			break;
		}
	}
	j=0;
	for(i=0;i<=n;i++)
	{
		if(a[i]==1)
		j++;
	}
	if(j==n-1) c=0;

	if(c) cout<<"NO";
	else cout<<"YES";

	return 0;
}

/*

*/


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<cctype>
#include <fstream>
#include <time.h>
#include <iterator>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;

vector<int>G[100010];
set<int>leaf;
bool isleaf[100010];
void dfs(int n, int pre) {
	bool found = false;
	int cnt= 0;
	if(n==0)for (auto x : G[n]) {
		cnt++;
	}
	if (cnt == 1) {
		leaf.insert(n);
		isleaf[n] = 1;
	}
	for (auto x : G[n]) {
		if (x == pre)continue;
		found = true;
		dfs(x, n);
	}
	if (!found) {
		leaf.insert(n);
		isleaf[n] = 1;
	}
}
int N;
bool check() {
	if (leaf.size() <= 2)return false;
	bool ok = true;
	for (auto x : leaf) {
		ok = false;
		for (auto y : G[x]) {
			for (auto z : G[y]) {
				if (z == x)continue;
				if (leaf.find(z) != leaf.end()) {
					ok = true;
					goto END;
				}
			}
		}
	END:;
		if (!ok)return false;
	}
	REP(i, N) {
		if (!isleaf[i]) {
			int cnt = 0;
			for (auto x : G[i]) {
				if (isleaf[x])cnt++;
			}
			if (cnt <= 1)return false;
		}
	}
	return true;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;

	REP(i, N - 1) {
		int u, v; cin >> u >> v;
		u-- , v-- ;
		G[u].pb(v);
		G[v].pb(u);
	}
	dfs(0, 0);
	if (N == 2) {
		print("YES"); return 0;
	}
	if (check())print("YES")else print("NO");
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<cctype>
#include <fstream>
#include <time.h>
#include <iterator>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;

vector<int>G[100010];
set<int>leaf;

void dfs(int n, int pre) {
	bool found = false;
	int cnt= 0;
	if(n==0)for (auto x : G[n]) {
		cnt++;
	}
	if (cnt == 1)leaf.insert(n);
	for (auto x : G[n]) {
		if (x == pre)continue;
		found = true;
		dfs(x, n);
	}
	if (!found)leaf.insert(n);
}
bool check() {
	if (leaf.size() <= 2)return false;
	bool ok = true;
	for (auto x : leaf) {
		ok = false;
		for (auto y : G[x]) {
			for (auto z : G[y]) {
				if (z == x)continue;
				if (leaf.find(z) != leaf.end()) {
					ok = true;
					goto END;
				}
			}
		}
	END:;
		if (!ok)return false;
	}
	return true;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;

	REP(i, N - 1) {
		int u, v; cin >> u >> v;
		u-- , v-- ;
		G[u].pb(v);
		G[v].pb(u);
	}
	dfs(0, 0);
	if (N == 2) {
		print("YES"); return 0;
	}
	if (check())print("YES")else print("NO");
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<cctype>
#include <fstream>
#include <time.h>
#include <iterator>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;

vector<int>G[100010];
set<int>leaf;
bool isleaf[100010];
void dfs(int n, int pre) {
	bool found = false;
	int cnt= 0;
	if(n==0)for (auto x : G[n]) {
		cnt++;
	}
	if (cnt == 1) {
		leaf.insert(n);
		isleaf[n] = 1;
	}
	for (auto x : G[n]) {
		if (x == pre)continue;
		found = true;
		dfs(x, n);
	}
	if (!found) {
		leaf.insert(n);
		isleaf[n] = 1;
	}
}
int N;
bool check() {
	if (leaf.size() <= 2)return false;
	bool ok = true;
	for (auto x : leaf) {
		ok = false;
		for (auto y : G[x]) {
			for (auto z : G[y]) {
				if (z == x)continue;
				if (leaf.find(z) != leaf.end()) {
					ok = true;
					goto END;
				}
			}
		}
	END:;
		if (!ok)return false;
	}
	REP(i, N) {
		if (!isleaf[i]) {
			int cnt = 0;
			for (auto x : G[i]) {
				if (isleaf[x])cnt++;
			}
			if (cnt <= 1)return false;
		}
	}
	return true;
}
bool check2() {
	REP(i, N) {
		int cnt = 0;
		for (auto x : G[i]) {
			cnt++;
		}
		//print(cnt);
		if (cnt == 2)return false;
	}
	return true;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	 cin >> N;

	REP(i, N - 1) {
		int u, v; cin >> u >> v;
		u-- , v-- ;
		G[u].pb(v);
		G[v].pb(u);
	}
	/*dfs(0, 0);
	if (N == 2) {
		print("YES"); return 0;
	}
	if (check())print("YES")else print("NO");*/
	if (check2())print("YES")else print("NO");
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<cctype>
#include <fstream>
#include <time.h>
#include <iterator>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;

vector<int>G[100010];
set<int>leaf;

void dfs(int n, int pre) {
	bool found = false;
	for (auto x : G[n]) {
		if (x == pre)continue;
		found = true;
		dfs(x, n);
	}
	if (!found)leaf.insert(n);
}
bool check() {
	if (leaf.size() <= 2)return false;
	bool ok = true;
	for (auto x : leaf) {
		ok = false;
		for (auto y : G[x]) {
			for (auto z : G[y]) {
				if (z == x)continue;
				if (leaf.find(z) != leaf.end()) {
					ok = true;
					goto END;
				}
			}
		}
	END:;
		if (!ok)return false;
	}
	return true;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;

	REP(i, N - 1) {
		int u, v; cin >> u >> v;
		u-- , v-- ;
		G[u].pb(v);
		G[v].pb(u);
	}
	dfs(0, 0);
	if (N == 2) {
		print("YES"); return 0;
	}
	if (check())print("YES")else print("NO");
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,x[maxn];
int main()
{
	scanf("%d",&n);
	int a,b;
	for(int i=1;i<=n-1;i++) scanf("%d%d",&a,&b),x[a]++,x[b]++;
	int f=0;
	int ct=0;
	for(int i=1;i<=n;i++)
	{
		if(x[i]%2==0)
		{
			f=1;
			break;
		}
	}
	if(!f)printf("YES");
	else printf("NO");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,x[maxn];
int main()
{
	scanf("%d",&n);
	int a,b;
	for(int i=1;i<=n-1;i++) scanf("%d%d",&a,&b),x[a]++,x[b]++;
	int f=0;
	int ct=0;
	for(int i=1;i<=n;i++)
	{
		if(x[i]==2)
		{
			f=1;
			break;
		}
	}
	if(!f)printf("YES");
	else printf("NO");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,x[maxn];
int main()
{
	scanf("%d",&n);
	int a,b;
	for(int i=1;i<=n-1;i++) scanf("%d%d",&a,&b),x[a]++,x[b]++;
	int f=0;
	for(int i=1;i<=n;i++)
	{
		if(x[a]%2==0)
		{
			f=1;
			break;
		}
	}
	if(!f)printf("YES");
	else printf("NO");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,x[maxn];
int main()
{
	scanf("%d",&n);
	int a,b;
	for(int i=1;i<=n-1;i++) scanf("%d%d",&a,&b),x[a]++,x[b]++;
	int f=0;
	for(int i=1;i<=n;i++)
	{
		if(x[a]==2)
		{
			f=1;
			break;
		}
	}
	if(!f)printf("YES");
	else printf("NO");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll Ceil(ll a, ll b){
    if(a%b==0){
        return a/b;
    } return a/b+1;
}
ll  minn(ll a , ll b){
    if(a < b){
        return a;
    }
    return b;
}

ll maxx(ll a, ll b){
    return a+b-minn(a,b);
}

int main() {
    ll n;
    cin>>n;
    map<ll, ll> degree;
    vector<pair<ll, ll> > edges;
    for(int i = 0;i<n-1;i++){
        ll a, b;
        cin>>a>>b;
        degree[a]+=1;
        degree[b]+=1;
        pair<ll,ll> c;
        c.first = a;
        c.second  = b;
        edges.push_back(c);
    }

    ll flag =1;
    // cout<<degree[2]<<" "<<degree[1]<<"\n";
    for(int i = 0;i<edges.size();i++){

        if((degree[edges[i].first]<=2 or degree[edges[i].second]<=2) and n>2)
        {
            flag = 0;
            break;
        }
    }
    // for(auto i = edges.begin();i!=edges.end();i++){
    //     if(b.find(*i.first)==b.end() && b.find(*i.second)==b.end()){
    //         flag = 0;
    //         break;
    //     }
    // }
    if(flag){
        cout<<"YES";
    }else{
        cout<<"NO";
    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll Ceil(ll a, ll b){
    if(a%b==0){
        return a/b;
    } return a/b+1;
}
ll  minn(ll a , ll b){
    if(a < b){
        return a;
    }
    return b;
}

ll maxx(ll a, ll b){
    return a+b-minn(a,b);
}

int main() {
    ll n;
    cin>>n;
    map<ll, ll> degree;
    vector<pair<ll, ll> > edges;
    for(int i = 0;i<n-1;i++){
        ll a, b;
        cin>>a>>b;
        degree[a]+=1;
        degree[b]+=1;
        pair<ll,ll> c;
        c.first = a;
        c.second  = b;
        edges.push_back(c);
    }

    ll flag =1;
    for(int i = 0;i<edges.size();i++){
        if(degree[edges[i].first]==1 and degree[edges[i].second]==1){
            continue;
        }
        if(degree[edges[i].first]<=2 and degree[edges[i].second]<=2)
        {
            flag = 0;
            break;
        }
    }
    // for(auto i = edges.begin();i!=edges.end();i++){
    //     if(b.find(*i.first)==b.end() && b.find(*i.second)==b.end()){
    //         flag = 0;
    //         break;
    //     }
    // }
    if(flag){
        cout<<"YES";
    }else{
        cout<<"NO";
    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll Ceil(ll a, ll b){
    if(a%b==0){
        return a/b;
    } return a/b+1;
}
ll  minn(ll a , ll b){
    if(a < b){
        return a;
    }
    return b;
}

ll maxx(ll a, ll b){
    return a+b-minn(a,b);
}

int main() {
    ll n;
    cin>>n;
    map<ll, ll> degree;
    vector<pair<ll, ll> > edges;
    for(int i = 0;i<n-1;i++){
        ll a, b;
        cin>>a>>b;
        degree[a]+=1;
        degree[b]+=1;
        pair<ll,ll> c;
        c.first = a;
        c.second  = b;
        edges.push_back(c);
    }

    ll flag =0;
    for(int i = 0;i<edges.size();i++){
        if(degree[edges[i].first]==1 and degree[edges[i].second]==1)
        continue;
        if(degree[edges[i].first]==1 and degree[edges[i].second]==2)
        {
            flag = 1;
            break;
        }
        if(degree[edges[i].first]==1 and degree[edges[i].second]>2)
        continue;
        if(degree[edges[i].first]==2 and degree[edges[i].second]==1)
        {
            flag= 1;
            break;
        }
        if(degree[edges[i].first]==2 and degree[edges[i].second]==2){
            flag= 1;
            break;
        }
        if(degree[edges[i].first]==2 and degree[edges[i].second]>2){
            flag= 1;
            break;
        }
        if(degree[edges[i].first]>2 and degree[edges[i].second]==1){
            continue;
        }
        if(degree[edges[i].first]>2 and degree[edges[i].second]==2){
            flag= 1;
            break;
        }
        if(degree[edges[i].first]>2 and degree[edges[i].second]>2){
            continue;
        }
    }
    // for(auto i = edges.begin();i!=edges.end();i++){
    //     if(b.find(*i.first)==b.end() && b.find(*i.second)==b.end()){
    //         flag = 0;
    //         break;
    //     }
    // }
    if(!flag){
        cout<<"YES";
    }else{
        cout<<"NO";
    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll Ceil(ll a, ll b){
    if(a%b==0){
        return a/b;
    } return a/b+1;
}
ll  minn(ll a , ll b){
    if(a < b){
        return a;
    }
    return b;
}

ll maxx(ll a, ll b){
    return a+b-minn(a,b);
}

int main() {
    ll n;
    cin>>n;
    map<ll, ll> degree;
    vector<pair<ll, ll> > edges;
    for(int i = 0;i<n-1;i++){
        ll a, b;
        cin>>a>>b;
        degree[a]+=1;
        degree[b]+=1;
        pair<ll,ll> c;
        c.first = a;
        c.second  = b;
        edges.push_back(c);
    }

    ll flag =1;
    for(int i = 0;i<edges.size();i++){
        if(degree[edges[i].first]==1 and degree[edges[i].second]==1 and n==2){
            continue;
        }
        if(degree[edges[i].first]<=2 and degree[edges[i].second]<=2)
        {
            flag = 0;
            break;
        }
    }
    // for(auto i = edges.begin();i!=edges.end();i++){
    //     if(b.find(*i.first)==b.end() && b.find(*i.second)==b.end()){
    //         flag = 0;
    //         break;
    //     }
    // }
    if(flag){
        cout<<"YES";
    }else{
        cout<<"NO";
    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll Ceil(ll a, ll b){
    if(a%b==0){
        return a/b;
    } return a/b+1;
}
ll  minn(ll a , ll b){
    if(a < b){
        return a;
    }
    return b;
}

ll maxx(ll a, ll b){
    return a+b-minn(a,b);
}

int main() {
    ll n;
    cin>>n;
    map<ll, ll> degree;
    vector<pair<ll, ll> > edges;
    for(int i = 0;i<n-1;i++){
        ll a, b;
        cin>>a>>b;
        degree[a]+=1;
        degree[b]+=1;
        pair<ll,ll> c;
        c.first = a;
        c.second  = b;
        edges.push_back(c);
    }

    ll flag =1;
    for(int i = 0;i<edges.size();i++){
        if(degree[edges[i].first]==1 and degree[edges[i].second]==1 and n!=2){
            flag = 0;
            break;
        }
        if(degree[edges[i].first]<=2 and degree[edges[i].second]<=2)
        {
            flag = 0;
            break;
        }
    }
    // for(auto i = edges.begin();i!=edges.end();i++){
    //     if(b.find(*i.first)==b.end() && b.find(*i.second)==b.end()){
    //         flag = 0;
    //         break;
    //     }
    // }
    if(flag){
        cout<<"YES";
    }else{
        cout<<"NO";
    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll Ceil(ll a, ll b){
    if(a%b==0){
        return a/b;
    } return a/b+1;
}
ll  minn(ll a , ll b){
    if(a < b){
        return a;
    }
    return b;
}

ll maxx(ll a, ll b){
    return a+b-minn(a,b);
}

int main() {
    ll n;
    cin>>n;
    map<ll, ll> degree;
    vector<pair<ll, ll> > edges;
    for(int i = 0;i<n-1;i++){
        ll a, b;
        cin>>a>>b;
        degree[a]+=1;
        degree[b]+=1;
        pair<ll,ll> c;
        c.first = a;
        c.second  = b;
        edges.push_back(c);
    }

    ll flag =1;
    cout<<degree[2]<<" "<<degree[1]<<"\n";
    for(int i = 0;i<edges.size();i++){

        if((degree[edges[i].first]<=2 or degree[edges[i].second]<=2) and n>2)
        {
            flag = 0;
            break;
        }
    }
    // for(auto i = edges.begin();i!=edges.end();i++){
    //     if(b.find(*i.first)==b.end() && b.find(*i.second)==b.end()){
    //         flag = 0;
    //         break;
    //     }
    // }
    if(flag){
        cout<<"YES";
    }else{
        cout<<"NO";
    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll Ceil(ll a, ll b){
    if(a%b==0){
        return a/b;
    } return a/b+1;
}
ll  minn(ll a , ll b){
    if(a < b){
        return a;
    }
    return b;
}

ll maxx(ll a, ll b){
    return a+b-minn(a,b);
}

int main() {
    ll n;
    cin>>n;
    map<ll, ll> degree;
    vector<pair<ll, ll> > edges;
    for(int i = 0;i<n-1;i++){
        ll a, b;
        cin>>a>>b;
        degree[a]+=1;
        degree[b]+=1;
        pair<ll,ll> c;
        c.first = a;
        c.second  = b;
        edges.push_back(c);
    }

    ll flag =0;
    for(int i = 0;i<edges.size();i++){
        if(degree[edges[i].first]==1 and degree[edges[i].second]==1)
        continue;
        if(degree[edges[i].first]==1 and degree[edges[i].second]==2)
        {
            flag = 1;
            break;
        }
        if(degree[edges[i].first]==1 and degree[edges[i].second]>2)
        continue;
        if(degree[edges[i].first]==2 and degree[edges[i].second]==1)
        {
            flag= 1;
            break;
        }
        if(degree[edges[i].first]==2 and degree[edges[i].second]==2){
            flag= 1;
            break;
        }
        if(degree[edges[i].first]==2 and degree[edges[i].second]>2){
            flag= 1;
            break;
        }
        if(degree[edges[i].first]>2 and degree[edges[i].second]==1){
            flag= 1;
            break;
        }
        if(degree[edges[i].first]>2 and degree[edges[i].second]==2){
            flag= 1;
            break;
        }
        if(degree[edges[i].first]>2 and degree[edges[i].second]>2){
            continue;
        }
    }
    // for(auto i = edges.begin();i!=edges.end();i++){
    //     if(b.find(*i.first)==b.end() && b.find(*i.second)==b.end()){
    //         flag = 0;
    //         break;
    //     }
    // }
    if(!flag){
        cout<<"YES";
    }else{
        cout<<"NO";
    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll Ceil(ll a, ll b){
    if(a%b==0){
        return a/b;
    } return a/b+1;
}
ll  minn(ll a , ll b){
    if(a < b){
        return a;
    }
    return b;
}

ll maxx(ll a, ll b){
    return a+b-minn(a,b);
}

int main() {
    ll n;
    cin>>n;
    map<ll, ll> degree;
    vector<pair<ll, ll> > edges;
    for(int i = 0;i<n-1;i++){
        ll a, b;
        cin>>a>>b;
        degree[a]+=1;
        degree[b]+=1;
        pair<ll,ll> c;
        c.first = a;
        c.second  = b;
        edges.push_back(c);
    }

    ll flag =1;
    for(int i = 0;i<edges.size();i++){
        if(degree[edges[i].first]==1 and degree[edges[i].second]==1 and n!=2){
            flag = 0;
            break;
        }
        if(degree[edges[i].first]<=2 and degree[edges[i].second]<=2 and n>2)
        {
            flag = 0;
            break;
        }
    }
    // for(auto i = edges.begin();i!=edges.end();i++){
    //     if(b.find(*i.first)==b.end() && b.find(*i.second)==b.end()){
    //         flag = 0;
    //         break;
    //     }
    // }
    if(flag){
        cout<<"YES";
    }else{
        cout<<"NO";
    }

}


#include <bits/stdc++.h>
#include <string.h>
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define F first
#define S second
#define pb push_back
#define po pop_back()
#define R return
#define C continue
#define B break
#define mp make_pair
#define all(v) v.begin(),v.end()
#define endl '\n'
#define loop(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define vi vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define sll set<ll>
#define in insert
#define be begin()
#define si size()
#define oo 1e18
#define debug(x,s) cout << #x << " = " <<  x << s;
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int mod=1000000009 ;
const double PI = 3.14159265;
//vi prime;
//bool is_composite[100000009];
//void sieve (int n) {
//	fill (is_composite, is_composite + n, false);
//	for (int i = 2; i < n; ++i) {
//		if (!is_composite[i]) prime.push_back (i);
//		for (int j = 0; j < prime.size () && i * prime[j] < n; ++j) {
//			is_composite[i * prime[j]] = true;
//			if (i % prime[j] == 0) break;
//		}
//	}
//}
string add(string s1,string s2){
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    string ss = "";
    int i = 0,j = 0,nxt = 0;
    while(i<s1.size()||j<s2.size()||nxt){
        int temp = (i<s1.size()?s1[i]-'0':0)+(j<s2.size()?s2[j]-'0':0)+nxt;
        ss.push_back(temp%10+'0');
        nxt = temp/10;
        i++,j++;
    }
    reverse(ss.begin(),ss.end());
    return ss;
}
void yes(){cout << "YES" << '\n';}
void no(){cout << "NO" << '\n';}
//void factorial() {fact[0]=1;for(int i=1;i<1e6+10;i++) {fact[i]=(fact[i-1]*i);fact[i]%=mod;}}
bool cmp(const pair<int,string> &a,const pair<int,string> &b){return (a.F > b.F);}
ll ceil(ll x,ll y){return x%y ? x/y+1 : x/y;}
ll power(ll x,ll y,ll mo){ll r=1; x=x%mo; while(y){ if(y&1) r= (r*x%mo)%mo; y=y>>1; x=((x%mo)*(x%mo))%mo; } return r%mo; }
ll gcd(ll x , ll y){return y ? gcd(y,x%y):x;}
ll fac(ll x){return (x ? x*fac(x-1) : 1 );}
ll inv(ll x,ll y){return (x*power(y,mod-2,mod))%mod;}
//ll Twafiq1(int n, int r){ll res = fact[n];ll div=fact[n-r]*fact[r];div%=mod;div=power(div,mod-2,mod);return(res*div)%mod;}
ll Twafiq(int n, int r){ll res = fac(n);ll div=fac(n-r)*fac(r);div%=mod;div=power(div,mod-2,mod);return(res*div)%mod;}

/*************************************/
ll n ;
vector<ll> v[100010];
bool vis[100010];
bool ok=1;
void dfs(int s){
    vis[s]=1;
    int cnt=0;
    for(int i=0;i<v[s].si;i++){
        if(vis[v[s][i]])continue;
        if(v[v[s][i]].si==1) cnt++;
        dfs(v[s][i]);
    }
    if(cnt<2 && v[s].si!=1)  ok=0;
}
int main()
{
    FastIO
    cin >> n;
    for(int i=0;i<n-1;i++){
        ll a , b;
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    for(int i=1;i<=n;i++){
        if(v[i].si==2)return no();
    }
    yes();
}


#include <bits/stdc++.h>
#include <string.h>
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define F first
#define S second
#define pb push_back
#define po pop_back()
#define R return
#define C continue
#define B break
#define mp make_pair
#define all(v) v.begin(),v.end()
#define endl '\n'
#define loop(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define vi vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define sll set<ll>
#define in insert
#define be begin()
#define si size()
#define oo 1e18
#define debug(x,s) cout << #x << " = " <<  x << s;
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int mod=1000000009 ;
const double PI = 3.14159265;
//vi prime;
//bool is_composite[100000009];
//void sieve (int n) {
//	fill (is_composite, is_composite + n, false);
//	for (int i = 2; i < n; ++i) {
//		if (!is_composite[i]) prime.push_back (i);
//		for (int j = 0; j < prime.size () && i * prime[j] < n; ++j) {
//			is_composite[i * prime[j]] = true;
//			if (i % prime[j] == 0) break;
//		}
//	}
//}
string add(string s1,string s2){
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    string ss = "";
    int i = 0,j = 0,nxt = 0;
    while(i<s1.size()||j<s2.size()||nxt){
        int temp = (i<s1.size()?s1[i]-'0':0)+(j<s2.size()?s2[j]-'0':0)+nxt;
        ss.push_back(temp%10+'0');
        nxt = temp/10;
        i++,j++;
    }
    reverse(ss.begin(),ss.end());
    return ss;
}
void yes(){cout << "YES" << '\n';}
void no(){cout << "NO" << '\n';}
//void factorial() {fact[0]=1;for(int i=1;i<1e6+10;i++) {fact[i]=(fact[i-1]*i);fact[i]%=mod;}}
bool cmp(const pair<int,string> &a,const pair<int,string> &b){return (a.F > b.F);}
ll ceil(ll x,ll y){return x%y ? x/y+1 : x/y;}
ll power(ll x,ll y,ll mo){ll r=1; x=x%mo; while(y){ if(y&1) r= (r*x%mo)%mo; y=y>>1; x=((x%mo)*(x%mo))%mo; } return r%mo; }
ll gcd(ll x , ll y){return y ? gcd(y,x%y):x;}
ll fac(ll x){return (x ? x*fac(x-1) : 1 );}
ll inv(ll x,ll y){return (x*power(y,mod-2,mod))%mod;}
//ll Twafiq1(int n, int r){ll res = fact[n];ll div=fact[n-r]*fact[r];div%=mod;div=power(div,mod-2,mod);return(res*div)%mod;}
ll Twafiq(int n, int r){ll res = fac(n);ll div=fac(n-r)*fac(r);div%=mod;div=power(div,mod-2,mod);return(res*div)%mod;}

/*************************************/
ll n ;
vector<ll> v[100010];
bool vis[100010];
bool ok=1;
void dfs(int s){
    vis[s]=1;
    int cnt=0;
    for(int i=0;i<v[s].si;i++){
        if(vis[v[s][i]])continue;
        if(v[v[s][i]].si==1) cnt++;
        dfs(v[s][i]);
    }
    if(cnt<2 && v[s].si!=1)  ok=0;
}
int main()
{
    FastIO
    cin >> n;
    for(int i=0;i<n-1;i++){
        ll a , b;
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs(1);
    cout << (ok ? "YES":"NO") << endl;
}


#include <bits/stdc++.h>
#include <string.h>
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define F first
#define S second
#define pb push_back
#define po pop_back()
#define R return
#define C continue
#define B break
#define mp make_pair
#define all(v) v.begin(),v.end()
#define endl '\n'
#define loop(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define vi vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define sll set<ll>
#define in insert
#define be begin()
#define si size()
#define oo 1e18
#define debug(x,s) cout << #x << " = " <<  x << s;
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int mod=1000000009 ;
const double PI = 3.14159265;
//vi prime;
//bool is_composite[100000009];
//void sieve (int n) {
//	fill (is_composite, is_composite + n, false);
//	for (int i = 2; i < n; ++i) {
//		if (!is_composite[i]) prime.push_back (i);
//		for (int j = 0; j < prime.size () && i * prime[j] < n; ++j) {
//			is_composite[i * prime[j]] = true;
//			if (i % prime[j] == 0) break;
//		}
//	}
//}
string add(string s1,string s2){
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    string ss = "";
    int i = 0,j = 0,nxt = 0;
    while(i<s1.size()||j<s2.size()||nxt){
        int temp = (i<s1.size()?s1[i]-'0':0)+(j<s2.size()?s2[j]-'0':0)+nxt;
        ss.push_back(temp%10+'0');
        nxt = temp/10;
        i++,j++;
    }
    reverse(ss.begin(),ss.end());
    return ss;
}
void yes(){cout << "YES" << '\n';}
void no(){cout << "NO" << '\n';}
//void factorial() {fact[0]=1;for(int i=1;i<1e6+10;i++) {fact[i]=(fact[i-1]*i);fact[i]%=mod;}}
bool cmp(const pair<int,string> &a,const pair<int,string> &b){return (a.F > b.F);}
ll ceil(ll x,ll y){return x%y ? x/y+1 : x/y;}
ll power(ll x,ll y,ll mo){ll r=1; x=x%mo; while(y){ if(y&1) r= (r*x%mo)%mo; y=y>>1; x=((x%mo)*(x%mo))%mo; } return r%mo; }
ll gcd(ll x , ll y){return y ? gcd(y,x%y):x;}
ll fac(ll x){return (x ? x*fac(x-1) : 1 );}
ll inv(ll x,ll y){return (x*power(y,mod-2,mod))%mod;}
//ll Twafiq1(int n, int r){ll res = fact[n];ll div=fact[n-r]*fact[r];div%=mod;div=power(div,mod-2,mod);return(res*div)%mod;}
ll Twafiq(int n, int r){ll res = fac(n);ll div=fac(n-r)*fac(r);div%=mod;div=power(div,mod-2,mod);return(res*div)%mod;}

/*************************************/
ll n ;
vector<ll> v[100010];
bool vis[100010];
bool ok=1;
void dfs(int s){
    vis[s]=1;
    int cnt=0;
    for(int i=0;i<v[s].si;i++){
        if(v[v[s][i]].si==1) cnt++;
        if(vis[v[s][i]])continue;
        dfs(v[s][i]);
    }
    if(cnt<2 && v[s].si!=1)  ok=0;
}
int main()
{
    FastIO
    cin >> n;
    if(n==3)return no(),0;
    for(int i=0;i<n-1;i++){
        ll a , b;
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs(1);
    cout << (ok ? "YES":"NO") << endl;
}


#include <bits/stdc++.h>
#include <string.h>
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define F first
#define S second
#define pb push_back
#define po pop_back()
#define R return
#define C continue
#define B break
#define mp make_pair
#define all(v) v.begin(),v.end()
#define endl '\n'
#define loop(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define vi vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define sll set<ll>
#define in insert
#define be begin()
#define si size()
#define oo 1e18
#define debug(x,s) cout << #x << " = " <<  x << s;
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int mod=1000000009 ;
const double PI = 3.14159265;
//vi prime;
//bool is_composite[100000009];
//void sieve (int n) {
//	fill (is_composite, is_composite + n, false);
//	for (int i = 2; i < n; ++i) {
//		if (!is_composite[i]) prime.push_back (i);
//		for (int j = 0; j < prime.size () && i * prime[j] < n; ++j) {
//			is_composite[i * prime[j]] = true;
//			if (i % prime[j] == 0) break;
//		}
//	}
//}
string add(string s1,string s2){
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    string ss = "";
    int i = 0,j = 0,nxt = 0;
    while(i<s1.size()||j<s2.size()||nxt){
        int temp = (i<s1.size()?s1[i]-'0':0)+(j<s2.size()?s2[j]-'0':0)+nxt;
        ss.push_back(temp%10+'0');
        nxt = temp/10;
        i++,j++;
    }
    reverse(ss.begin(),ss.end());
    return ss;
}
void yes(){cout << "YES" << '\n';}
void no(){cout << "NO" << '\n';}
//void factorial() {fact[0]=1;for(int i=1;i<1e6+10;i++) {fact[i]=(fact[i-1]*i);fact[i]%=mod;}}
bool cmp(const pair<int,string> &a,const pair<int,string> &b){return (a.F > b.F);}
ll ceil(ll x,ll y){return x%y ? x/y+1 : x/y;}
ll power(ll x,ll y,ll mo){ll r=1; x=x%mo; while(y){ if(y&1) r= (r*x%mo)%mo; y=y>>1; x=((x%mo)*(x%mo))%mo; } return r%mo; }
ll gcd(ll x , ll y){return y ? gcd(y,x%y):x;}
ll fac(ll x){return (x ? x*fac(x-1) : 1 );}
ll inv(ll x,ll y){return (x*power(y,mod-2,mod))%mod;}
//ll Twafiq1(int n, int r){ll res = fact[n];ll div=fact[n-r]*fact[r];div%=mod;div=power(div,mod-2,mod);return(res*div)%mod;}
ll Twafiq(int n, int r){ll res = fac(n);ll div=fac(n-r)*fac(r);div%=mod;div=power(div,mod-2,mod);return(res*div)%mod;}

/*************************************/
ll n ;
vector<ll> v[100010];
bool vis[100010];
bool ok=1;
void dfs(int s){
    vis[s]=1;
    int cnt=0;
    for(int i=0;i<v[s].si;i++){
        if(vis[v[s][i]])continue;
        if(v[v[s][i]].si==1) cnt++;
        dfs(v[s][i]);
    }
    if(cnt<2 && v[s].si!=1)  ok=0;
}
int main()
{
    FastIO
    cin >> n;
    for(int i=0;i<n-1;i++){
        ll a ,  b;
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs(1);
    cout << (ok ? "YES":"NO") << endl;
}


#include <bits/stdc++.h>
#include <string.h>
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define F first
#define S second
#define pb push_back
#define po pop_back()
#define R return
#define C continue
#define B break
#define mp make_pair
#define all(v) v.begin(),v.end()
#define endl '\n'
#define loop(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define vi vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define sll set<ll>
#define in insert
#define be begin()
#define si size()
#define oo 1e18
#define debug(x,s) cout << #x << " = " <<  x << s;
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int mod=1000000009 ;
const double PI = 3.14159265;
//vi prime;
//bool is_composite[100000009];
//void sieve (int n) {
//	fill (is_composite, is_composite + n, false);
//	for (int i = 2; i < n; ++i) {
//		if (!is_composite[i]) prime.push_back (i);
//		for (int j = 0; j < prime.size () && i * prime[j] < n; ++j) {
//			is_composite[i * prime[j]] = true;
//			if (i % prime[j] == 0) break;
//		}
//	}
//}
string add(string s1,string s2){
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    string ss = "";
    int i = 0,j = 0,nxt = 0;
    while(i<s1.size()||j<s2.size()||nxt){
        int temp = (i<s1.size()?s1[i]-'0':0)+(j<s2.size()?s2[j]-'0':0)+nxt;
        ss.push_back(temp%10+'0');
        nxt = temp/10;
        i++,j++;
    }
    reverse(ss.begin(),ss.end());
    return ss;
}
void yes(){cout << "YES" << '\n';}
void no(){cout << "NO" << '\n';}
//void factorial() {fact[0]=1;for(int i=1;i<1e6+10;i++) {fact[i]=(fact[i-1]*i);fact[i]%=mod;}}
bool cmp(const pair<int,string> &a,const pair<int,string> &b){return (a.F > b.F);}
ll ceil(ll x,ll y){return x%y ? x/y+1 : x/y;}
ll power(ll x,ll y,ll mo){ll r=1; x=x%mo; while(y){ if(y&1) r= (r*x%mo)%mo; y=y>>1; x=((x%mo)*(x%mo))%mo; } return r%mo; }
ll gcd(ll x , ll y){return y ? gcd(y,x%y):x;}
ll fac(ll x){return (x ? x*fac(x-1) : 1 );}
ll inv(ll x,ll y){return (x*power(y,mod-2,mod))%mod;}
//ll Twafiq1(int n, int r){ll res = fact[n];ll div=fact[n-r]*fact[r];div%=mod;div=power(div,mod-2,mod);return(res*div)%mod;}
ll Twafiq(int n, int r){ll res = fac(n);ll div=fac(n-r)*fac(r);div%=mod;div=power(div,mod-2,mod);return(res*div)%mod;}

/*************************************/
ll n ;
vector<ll> v[100010];
bool vis[100010];
bool ok=1;
void dfs(int s){
    vis[s]=1;
    int cnt=0;
    for(int i=0;i<v[s].si;i++){
        if(vis[v[s][i]])continue;
        if(v[v[s][i]].si==1) cnt++;
        dfs(v[s][i]);
    }
    if(cnt<2 && v[s].si!=1)  ok=0;
}
int main()
{
    FastIO
    cin >> n;
    for(int i=0;i<n-1;i++){
        ll a , b;
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    for(int i=1;i<=n;i++){
        if(v[i].si==2)return no(),0;
    }
    yes();
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define sc second
#define pb push_back
#define pii pair<ll,ll>
#define mod 1000000007
int main()
{
   ll n,i,a[500004],q;
   cin>>n;
   unordered_map<ll,ll>h;
   ll cnt=0;
   if(n==3)
   {
   	cout<<"NO"<<endl;
   	return 0;
   }
   vector<ll>v1;
    for(i=0;i<n-1;i++)
    {
        ll u,v;
        cin>>u>>v;
        h[u]++;
        v1.push_back(v);
    }
    for(i=0;i<v1.size();i++)
    {
        if(h[v1[i]]==0)
        cnt++;
    }
    ll j=cnt*(cnt-1)/2;
    if(j%2==0)
    cout<<"YES"<<endl;
    else
    {
        cout<<"NO"<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define sc second
#define pb push_back
#define pii pair<ll,ll>
#define mod 1000000007
int main()
{
   ll n,i,a[500004],q;
   cin>>n;
   unordered_map<ll,ll>h;
   ll cnt=0;
   vector<ll>v1;
    for(i=0;i<n-1;i++)
    {
        ll u,v;
        cin>>u>>v;
        h[u]++;
        h[v]++;
    }
    for(auto it=h.begin();it!=h.end();it++)
    {
    	if(it->sc==2)
    	cnt=1;
    }
    if(cnt==1)
    cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define sc second
#define pb push_back
#define pii pair<ll,ll>
#define mod 1000000007
int main()
{
   ll n,i,a[500004],q;
   cin>>n;
   unordered_map<ll,ll>h;
   ll cnt=0;
   if(n==3)
   {
   	cout<<"NO"<<endl;
   	return 0;
   }
   vector<ll>v1;
    for(i=0;i<n-1;i++)
    {
        ll u,v;
        cin>>u>>v;
        h[u]++;
        h[v]++;
    }
    for(auto it=h.begin();it!=h.end();it++)
    {
    	if(it->sc==1)
    	cnt++;
    }
    // for(i=0;i<v1.size();i++)
    // {
    //     if(h[v1[i]]==0)
    //     cnt++;
    // }
    ll j=cnt*(cnt-1)/2;
    if(n%2==1)
    cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define sc second
#define pb push_back
#define pii pair<ll,ll>
#define mod 1000000007
int main()
{
   ll n,i,a[500004],q;
   cin>>n;
   unordered_map<ll,ll>h;
   ll cnt=0;
   if(n==2)
   {
   	cout<<"YES"<<endl;
   	return 0;
   }
   vector<ll>v1;
    for(i=0;i<n-1;i++)
    {
        ll u,v;
        cin>>u>>v;
        h[u]++;
        v1.push_back(v);
    }
    for(i=0;i<v1.size();i++)
    {
        if(h[v1[i]]==0)
        cnt++;
    }
    ll j=cnt*(cnt-1)/2;
    if(cnt%2==1)
    cout<<"NO"<<endl;
    else
    {
    	if(j%2==1)
    	cout<<"NO"<<endl;
    	else
        cout<<"YES"<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define sc second
#define pb push_back
#define pii pair<ll,ll>
#define mod 1000000007
int main()
{
   ll n,i,a[500004],q;
   cin>>n;
   unordered_map<ll,ll>h;
   ll cnt=0;
   if(n==3)
   {
   	cout<<"NO"<<endl;
   	return 0;
   }
   vector<ll>v1;
    for(i=0;i<n-1;i++)
    {
        ll u,v;
        cin>>u>>v;
        h[u]++;
        h[v]++;
    }
    for(auto it=h.begin();it!=h.end();it++)
    {
    	if(it->sc==1)
    	cnt++;
    }
    // for(i=0;i<v1.size();i++)
    // {
    //     if(h[v1[i]]==0)
    //     cnt++;
    // }
    ll j=cnt*(cnt-1)/2;
    if(cnt%2==1)
    cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define sc second
#define pb push_back
#define pii pair<ll,ll>
#define mod 1000000007
int main()
{
   ll n,i,a[500004],q;
   cin>>n;
   unordered_map<ll,ll>h;
   ll cnt=0;
   if(n==2)
   {
   	cout<<"YES"<<endl;
   	return 0;
   }
   vector<ll>v1;
    for(i=0;i<n-1;i++)
    {
        ll u,v;
        cin>>u>>v;
        h[u]++;
        v1.push_back(v);
    }
    for(i=0;i<v1.size();i++)
    {
        if(h[v1[i]]==0)
        cnt++;
    }
    //ll j=cnt*(cnt-1)/2;
    if(cnt%2==1)
    cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
    }

}


 //kanishk aka codephilic//
 /*
 __   __    __ _ _ _
|  | /  /  |  _ _ _ |
|  |/  /   | |
|     /    | |  _____
|  |  \    | | |  _  |
|  |\  \   | |_| | | |
|__| \__\  |_____| |_|

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll            long long
#define pb            push_back
#define ppb           pop_back
#define si            set <ll>
#define endl          '\n'
#define F             first
#define S             second
#define mii           map<ll ,ll >
#define msi           map<string,ll >
#define mis           map<ll , string>
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define all(v)        v.begin(),v.end()
//#define sort(v)         sort(all(v))
#define pii           pair<ll ,ll >
#define vi            vector<ll >
#define vs            vector<string>
#define sz(x)         (ll )x.size()
#define sl(x)          (ll )x.length()
#define hell          1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)        rep(i,0,n)cin>>a[i]
#define fbo            find_by_order
#define ook            order_of_key
//#define abc   cin
//#define qwe   cout
using namespace std;
using namespace __gnu_pbds;
/*ll int lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
ll power(ll int base,ll int exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%hell;
       base=(base*base)%hell;
       exp/=2;
    }
    return res%hell;
}*/
ll n;
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//ifstream abc("input.txt");
//ofstream qwe("output.txt");
cin>>n;
vi v[n+1];
rep(i,0,n-1)
{
    ll x,y;
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);
}
mii m;
rep(i,1,n+1)
{
    m[sz(v[i])]++;
}
mii::iterator it=m.begin();
for(it;it!=m.end();it++)
{
    if(it->S%2==1||(it->F!=1&&it->F!=3))
    {
        cout<<"no";
        return 0;
    }
}
ll cnt=m[1];
while(cnt>1)
{
    cnt/=2;
    if(cnt!=1)
    if(cnt%2!=0)
        {
        cout<<"no";
        return 0;
    }
}
cout<<"yes";
return 0;
}


 //kanishk aka codephilic//
 /*
 __   __    __ _ _ _
|  | /  /  |  _ _ _ |
|  |/  /   | |
|     /    | |  _____
|  |  \    | | |  _  |
|  |\  \   | |_| | | |
|__| \__\  |_____| |_|

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll            long long
#define pb            push_back
#define ppb           pop_back
#define si            set <ll>
#define endl          '\n'
#define F             first
#define S             second
#define mii           map<ll ,ll >
#define msi           map<string,ll >
#define mis           map<ll , string>
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define all(v)        v.begin(),v.end()
//#define sort(v)         sort(all(v))
#define pii           pair<ll ,ll >
#define vi            vector<ll >
#define vs            vector<string>
#define sz(x)         (ll )x.size()
#define sl(x)          (ll )x.length()
#define hell          1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)        rep(i,0,n)cin>>a[i]
#define fbo            find_by_order
#define ook            order_of_key
//#define abc   cin
//#define qwe   cout
using namespace std;
using namespace __gnu_pbds;
/*ll int lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
ll power(ll int base,ll int exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%hell;
       base=(base*base)%hell;
       exp/=2;
    }
    return res%hell;
}*/
ll n;
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//ifstream abc("input.txt");
//ofstream qwe("output.txt");
cin>>n;
vi v[n+1];
rep(i,0,n-1)
{
    ll x,y;
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);
}
mii m;
rep(i,1,n+1)
{
    m[sz(v[i])]++;
}
mii::iterator it=m.begin();
for(it;it!=m.end();it++)
{
    if(it->S%2==1&&(it->F==1||it->F==3))
    {
        cout<<"no";
        return 0;
    }
}
cout<<"yes";
return 0;
}


 //kanishk aka codephilic//
 /*
 __   __    __ _ _ _
|  | /  /  |  _ _ _ |
|  |/  /   | |
|     /    | |  _____
|  |  \    | | |  _  |
|  |\  \   | |_| | | |
|__| \__\  |_____| |_|

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll            long long
#define pb            push_back
#define ppb           pop_back
#define si            set <ll>
#define endl          '\n'
#define F             first
#define S             second
#define mii           map<ll ,ll >
#define msi           map<string,ll >
#define mis           map<ll , string>
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define all(v)        v.begin(),v.end()
//#define sort(v)         sort(all(v))
#define pii           pair<ll ,ll >
#define vi            vector<ll >
#define vs            vector<string>
#define sz(x)         (ll )x.size()
#define sl(x)          (ll )x.length()
#define hell          1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)        rep(i,0,n)cin>>a[i]
#define fbo            find_by_order
#define ook            order_of_key
//#define abc   cin
//#define qwe   cout
using namespace std;
using namespace __gnu_pbds;
/*ll int lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
ll power(ll int base,ll int exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%hell;
       base=(base*base)%hell;
       exp/=2;
    }
    return res%hell;
}*/
ll n;
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//ifstream abc("input.txt");
//ofstream qwe("output.txt");
cin>>n;
vi v[n+1];
rep(i,0,n-1)
{
    ll x,y;
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);
}
mii m;
rep(i,1,n+1)
{
    m[sz(v[i])]++;
}
mii::iterator it=m.begin();
for(it;it!=m.end();it++)
{
    if(it->S%2==1||(it->F!=1&&it->F!=3))
    {
        cout<<"no";
        return 0;
    }
}
cout<<"yes";
return 0;
}


 //kanishk aka codephilic//
 /*
 __   __    __ _ _ _
|  | /  /  |  _ _ _ |
|  |/  /   | |
|     /    | |  _____
|  |  \    | | |  _  |
|  |\  \   | |_| | | |
|__| \__\  |_____| |_|

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll            long long
#define pb            push_back
#define ppb           pop_back
#define si            set <ll>
#define endl          '\n'
#define F             first
#define S             second
#define mii           map<ll ,ll >
#define msi           map<string,ll >
#define mis           map<ll , string>
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define all(v)        v.begin(),v.end()
//#define sort(v)         sort(all(v))
#define pii           pair<ll ,ll >
#define vi            vector<ll >
#define vs            vector<string>
#define sz(x)         (ll )x.size()
#define sl(x)          (ll )x.length()
#define hell          1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)        rep(i,0,n)cin>>a[i]
#define fbo            find_by_order
#define ook            order_of_key
//#define abc   cin
//#define qwe   cout
using namespace std;
using namespace __gnu_pbds;
/*ll int lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
ll power(ll int base,ll int exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%hell;
       base=(base*base)%hell;
       exp/=2;
    }
    return res%hell;
}*/
ll n;
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//ifstream abc("input.txt");
//ofstream qwe("output.txt");
cin>>n;
vi v[n+1];
rep(i,0,n-1)
{
    ll x,y;
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);
}
mii m;
rep(i,1,n+1)
{
    m[sz(v[i])]++;
}
mii::iterator it=m.begin();
for(it;it!=m.end();it++)
{
    if(it->S%2==1||(it->F!=1&&it->F!=3))
    {
        cout<<"no";
        return 0;
    }
}
ll cnt=m[1];
while(cnt>0)
{
    cnt/=2;
    if(cnt%2!=0)
        {
        cout<<"no";
        return 0;
    }
}
cout<<"yes";
return 0;
}


 //kanishk aka codephilic//
 /*
 __   __    __ _ _ _
|  | /  /  |  _ _ _ |
|  |/  /   | |
|     /    | |  _____
|  |  \    | | |  _  |
|  |\  \   | |_| | | |
|__| \__\  |_____| |_|

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll            long long
#define pb            push_back
#define ppb           pop_back
#define si            set <ll>
#define endl          '\n'
#define F             first
#define S             second
#define mii           map<ll ,ll >
#define msi           map<string,ll >
#define mis           map<ll , string>
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define all(v)        v.begin(),v.end()
//#define sort(v)         sort(all(v))
#define pii           pair<ll ,ll >
#define vi            vector<ll >
#define vs            vector<string>
#define sz(x)         (ll )x.size()
#define sl(x)          (ll )x.length()
#define hell          1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)        rep(i,0,n)cin>>a[i]
#define fbo            find_by_order
#define ook            order_of_key
//#define abc   cin
//#define qwe   cout
using namespace std;
using namespace __gnu_pbds;
/*ll int lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
ll power(ll int base,ll int exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%hell;
       base=(base*base)%hell;
       exp/=2;
    }
    return res%hell;
}*/
ll n;
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//ifstream abc("input.txt");
//ofstream qwe("output.txt");
cin>>n;
vi v[n+1];
rep(i,0,n-1)
{
    ll x,y;
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);
}
mii m;
rep(i,1,n+1)
{
    m[sz(v[i])]++;
}
mii::iterator it=m.begin();
for(it;it!=m.end();it++)
{
    if(it->S%2==1)
    {
        cout<<"no";
        return 0;
    }
}
cout<<"yes";
return 0;
}


 //kanishk aka codephilic//
 /*
 __   __    __ _ _ _
|  | /  /  |  _ _ _ |
|  |/  /   | |
|     /    | |  _____
|  |  \    | | |  _  |
|  |\  \   | |_| | | |
|__| \__\  |_____| |_|

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll            long long
#define pb            push_back
#define ppb           pop_back
#define si            set <ll>
#define endl          '\n'
#define F             first
#define S             second
#define mii           map<ll ,ll >
#define msi           map<string,ll >
#define mis           map<ll , string>
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define all(v)        v.begin(),v.end()
//#define sort(v)         sort(all(v))
#define pii           pair<ll ,ll >
#define vi            vector<ll >
#define vs            vector<string>
#define sz(x)         (ll )x.size()
#define sl(x)          (ll )x.length()
#define hell          1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)        rep(i,0,n)cin>>a[i]
#define fbo            find_by_order
#define ook            order_of_key
//#define abc   cin
//#define qwe   cout
using namespace std;
using namespace __gnu_pbds;
/*ll int lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
ll power(ll int base,ll int exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%hell;
       base=(base*base)%hell;
       exp/=2;
    }
    return res%hell;
}*/
ll n;
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//ifstream abc("input.txt");
//ofstream qwe("output.txt");
ll i,u,v;
    cin>>n;
    map<ll,ll> m;
    rep(i,0,n-1)
    {
        cin>>u>>v;
        m[u]++;
        m[v]++;
    }
    map<ll,ll>::iterator it;
    for(it=m.begin();it!=m.end();it++)
    {
        if(it->S==2)
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    ll n;
    cin>>n;
    vector<ll>v[n+1];
    for(ll i=0;i<n-1;i++)
    {
        ll u,x;
        cin>>u>>x;
        v[u].push_back(x);
        v[x].push_back(u);
    }
    ll f=0,ct1=0;
    for(ll i=1;i<=n;i++)
    {
        if(v[i].size()==2)
        f=1;

    }
   // ll ans=abs(ct-ct1);
    if(f==0)
    cout<<"YES";
    else
    cout<<"NO";
    /*
    ll arr[n];
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    ll sum[n+1];
    sum[0]=0;
    sum[1]=arr[0];
    for(ll i=1;i<n;i++)
    {
        sum[i+1]=sum[i]+arr[i];
    }
    ll q;
    cin>>q;
    while(q--)
    {
        ll l,r;
        cin>>l>>r;
        cout<<(sum[r]-sum[l-1])/10<<endl;
    }

    sort(arr,arr+n);
    int f=0;
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            if(arr[i]>=arr[i+1]+arr[n-1])
            {
                f=1;
                break;
            }
        }
        else if(i==n-1)
        {
            if(arr[i]>=arr[i-1]+arr[0])
            {
                f=1;
                break;
            }
        }
        else
        {
            if(arr[i]>=arr[i-1]+arr[i+1])
            {
                f=1;
                break;
            }
        }
    }

    if(f==1)
    {
        int sum=arr[n-2]+arr[n-3];
        if(sum<=arr[n-1])
        {
            cout<<"NO";
            return 0;
        }
        else
        {
            cout<<"YES"<<endl;
            for(int i=0;i<n-2;i++)
            cout<<arr[i]<<" ";
            cout<<arr[n-1]<<" "<<arr[n-2];

        }
    }
    else
    {
        cout<<"YES"<<endl;
        for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    }

    int n;
    cin>>n;
    string s;
    cin>>s;
    int ct=0,ct1=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0')
        ct++;
        else
        ct1++;
    }
    if(ct!=ct1)
    {
        cout<<"1"<<endl;
        cout<<s<<endl;
    }
    else
    {
        cout<<"2"<<endl;
        cout<<s[0]<<" ";
        for(int i=1;i<n;i++)
        cout<<s[i];
    }*/
   // cout << "Hello World!" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    ll n;
    cin>>n;
    vector<ll>v[n+1];
    for(ll i=0;i<n-1;i++)
    {
        ll u,x;
        cin>>u>>x;
        v[u].push_back(x);
        v[x].push_back(u);
    }
    ll ct=0,ct1=0;
    for(ll i=1;i<=n;i++)
    {
        if(v[i].size()%2==0)
        ct++;

    }
   // ll ans=abs(ct-ct1);
    if(ct%2==0)
    cout<<"YES";
    else
    cout<<"NO";
    /*
    ll arr[n];
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    ll sum[n+1];
    sum[0]=0;
    sum[1]=arr[0];
    for(ll i=1;i<n;i++)
    {
        sum[i+1]=sum[i]+arr[i];
    }
    ll q;
    cin>>q;
    while(q--)
    {
        ll l,r;
        cin>>l>>r;
        cout<<(sum[r]-sum[l-1])/10<<endl;
    }

    sort(arr,arr+n);
    int f=0;
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            if(arr[i]>=arr[i+1]+arr[n-1])
            {
                f=1;
                break;
            }
        }
        else if(i==n-1)
        {
            if(arr[i]>=arr[i-1]+arr[0])
            {
                f=1;
                break;
            }
        }
        else
        {
            if(arr[i]>=arr[i-1]+arr[i+1])
            {
                f=1;
                break;
            }
        }
    }

    if(f==1)
    {
        int sum=arr[n-2]+arr[n-3];
        if(sum<=arr[n-1])
        {
            cout<<"NO";
            return 0;
        }
        else
        {
            cout<<"YES"<<endl;
            for(int i=0;i<n-2;i++)
            cout<<arr[i]<<" ";
            cout<<arr[n-1]<<" "<<arr[n-2];

        }
    }
    else
    {
        cout<<"YES"<<endl;
        for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    }

    int n;
    cin>>n;
    string s;
    cin>>s;
    int ct=0,ct1=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0')
        ct++;
        else
        ct1++;
    }
    if(ct!=ct1)
    {
        cout<<"1"<<endl;
        cout<<s<<endl;
    }
    else
    {
        cout<<"2"<<endl;
        cout<<s[0]<<" ";
        for(int i=1;i<n;i++)
        cout<<s[i];
    }*/
   // cout << "Hello World!" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    ll n;
    cin>>n;
    vector<ll>v[n+1];
    for(ll i=0;i<n-1;i++)
    {
        ll u,x;
        cin>>u>>x;
        v[u].push_back(x);
        v[x].push_back(u);
    }
    ll ct=0,ct1=0;
    for(ll i=1;i<=n;i++)
    {
        if(v[i].size()==3 || v[i].size()==1)
        continue;
        else
        {
        ct=1;
        break;
        }

    }
   // ll ans=abs(ct-ct1);
    if(ct%2==0)
    cout<<"YES";
    else
    cout<<"NO";
    /*
    ll arr[n];
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    ll sum[n+1];
    sum[0]=0;
    sum[1]=arr[0];
    for(ll i=1;i<n;i++)
    {
        sum[i+1]=sum[i]+arr[i];
    }
    ll q;
    cin>>q;
    while(q--)
    {
        ll l,r;
        cin>>l>>r;
        cout<<(sum[r]-sum[l-1])/10<<endl;
    }

    sort(arr,arr+n);
    int f=0;
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            if(arr[i]>=arr[i+1]+arr[n-1])
            {
                f=1;
                break;
            }
        }
        else if(i==n-1)
        {
            if(arr[i]>=arr[i-1]+arr[0])
            {
                f=1;
                break;
            }
        }
        else
        {
            if(arr[i]>=arr[i-1]+arr[i+1])
            {
                f=1;
                break;
            }
        }
    }

    if(f==1)
    {
        int sum=arr[n-2]+arr[n-3];
        if(sum<=arr[n-1])
        {
            cout<<"NO";
            return 0;
        }
        else
        {
            cout<<"YES"<<endl;
            for(int i=0;i<n-2;i++)
            cout<<arr[i]<<" ";
            cout<<arr[n-1]<<" "<<arr[n-2];

        }
    }
    else
    {
        cout<<"YES"<<endl;
        for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    }

    int n;
    cin>>n;
    string s;
    cin>>s;
    int ct=0,ct1=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0')
        ct++;
        else
        ct1++;
    }
    if(ct!=ct1)
    {
        cout<<"1"<<endl;
        cout<<s<<endl;
    }
    else
    {
        cout<<"2"<<endl;
        cout<<s[0]<<" ";
        for(int i=1;i<n;i++)
        cout<<s[i];
    }*/
   // cout << "Hello World!" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    ll n;
    cin>>n;
    vector<ll>v[n+1];
    for(ll i=0;i<n-1;i++)
    {
        ll u,x;
        cin>>u>>x;
        v[u].push_back(x);
        v[x].push_back(u);
    }
    ll ct=0,ct1=0;
    for(ll i=1;i<=n;i++)
    {
        if(v[i].size()%2==0)
        ct=1;

    }
   // ll ans=abs(ct-ct1);
    if(ct==0)
    cout<<"YES";
    else
    cout<<"NO";
    /*
    ll arr[n];
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    ll sum[n+1];
    sum[0]=0;
    sum[1]=arr[0];
    for(ll i=1;i<n;i++)
    {
        sum[i+1]=sum[i]+arr[i];
    }
    ll q;
    cin>>q;
    while(q--)
    {
        ll l,r;
        cin>>l>>r;
        cout<<(sum[r]-sum[l-1])/10<<endl;
    }

    sort(arr,arr+n);
    int f=0;
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            if(arr[i]>=arr[i+1]+arr[n-1])
            {
                f=1;
                break;
            }
        }
        else if(i==n-1)
        {
            if(arr[i]>=arr[i-1]+arr[0])
            {
                f=1;
                break;
            }
        }
        else
        {
            if(arr[i]>=arr[i-1]+arr[i+1])
            {
                f=1;
                break;
            }
        }
    }

    if(f==1)
    {
        int sum=arr[n-2]+arr[n-3];
        if(sum<=arr[n-1])
        {
            cout<<"NO";
            return 0;
        }
        else
        {
            cout<<"YES"<<endl;
            for(int i=0;i<n-2;i++)
            cout<<arr[i]<<" ";
            cout<<arr[n-1]<<" "<<arr[n-2];

        }
    }
    else
    {
        cout<<"YES"<<endl;
        for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    }

    int n;
    cin>>n;
    string s;
    cin>>s;
    int ct=0,ct1=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0')
        ct++;
        else
        ct1++;
    }
    if(ct!=ct1)
    {
        cout<<"1"<<endl;
        cout<<s<<endl;
    }
    else
    {
        cout<<"2"<<endl;
        cout<<s[0]<<" ";
        for(int i=1;i<n;i++)
        cout<<s[i];
    }*/
   // cout << "Hello World!" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    ll n;
    cin>>n;
    vector<ll>v[n+1];
    for(ll i=0;i<n-1;i++)
    {
        ll u,x;
        cin>>u>>x;
        v[u].push_back(x);
        v[x].push_back(u);
    }
    ll ct=0,ct1=0;
    for(ll i=1;i<=n;i++)
    {
        if(v[i].size()==1)
        ct++;
        else if(v[i].size()>1)
        {
            ct1++;
        }
    }
    ll ans=abs(ct-ct1);
    if(ans%2==0)
    cout<<"YES";
    else
    cout<<"NO";
    /*
    ll arr[n];
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    ll sum[n+1];
    sum[0]=0;
    sum[1]=arr[0];
    for(ll i=1;i<n;i++)
    {
        sum[i+1]=sum[i]+arr[i];
    }
    ll q;
    cin>>q;
    while(q--)
    {
        ll l,r;
        cin>>l>>r;
        cout<<(sum[r]-sum[l-1])/10<<endl;
    }

    sort(arr,arr+n);
    int f=0;
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            if(arr[i]>=arr[i+1]+arr[n-1])
            {
                f=1;
                break;
            }
        }
        else if(i==n-1)
        {
            if(arr[i]>=arr[i-1]+arr[0])
            {
                f=1;
                break;
            }
        }
        else
        {
            if(arr[i]>=arr[i-1]+arr[i+1])
            {
                f=1;
                break;
            }
        }
    }

    if(f==1)
    {
        int sum=arr[n-2]+arr[n-3];
        if(sum<=arr[n-1])
        {
            cout<<"NO";
            return 0;
        }
        else
        {
            cout<<"YES"<<endl;
            for(int i=0;i<n-2;i++)
            cout<<arr[i]<<" ";
            cout<<arr[n-1]<<" "<<arr[n-2];

        }
    }
    else
    {
        cout<<"YES"<<endl;
        for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    }

    int n;
    cin>>n;
    string s;
    cin>>s;
    int ct=0,ct1=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0')
        ct++;
        else
        ct1++;
    }
    if(ct!=ct1)
    {
        cout<<"1"<<endl;
        cout<<s<<endl;
    }
    else
    {
        cout<<"2"<<endl;
        cout<<s[0]<<" ";
        for(int i=1;i<n;i++)
        cout<<s[i];
    }*/
   // cout << "Hello World!" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
vector<int>v[100005];
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    if(n==2){
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    for(int i=1;i<=n;i++){
        if(v[i].size()-(i!=1) == 1 ){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
vector<int>v[100005];
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    if(n==2){
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    for(int i=2;i<=n;i++){
        if(v[i].size()-1 == 1 ){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
vector<int>v[100005];
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    if(n==2){
        cout<<"YES"<<endl;
        return 0;
    }
    else if(n==3){
        cout<<"NO";
        return 0;
    }
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    if(v[1]==2){
        cout<<"NO";
        return 0;
    }
    for(int i=2;i<=n;i++){
        if(v[i].size()-1 == 1 ){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
vector<int>v[100005];
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    if(n==2){
        cout<<"YES"<<endl;
        return 0;
    }
    else if(n==3){
        cout<<"NO";
        return 0;
    }
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    if(v[1].size()==2){
        cout<<"NO";
        return 0;
    }
    for(int i=2;i<=n;i++){
        if(v[i].size()-1 == 1 ){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
int fre[200005];
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    if(n==2){
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        fre[a]++;
    }
    for(int i=1;i<=n;i++){
        if(fre[i]==1){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
vector<int>v[100005];
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    if(n==2){
        cout<<"YES"<<endl;
        return 0;
    }
    else if(n==3){
        cout<<"NO";
        return 0;
    }
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    for(int i=2;i<=n;i++){
        if(v[i].size()-1 == 1 ){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
return 0;
}


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

#define ll           long long
#define pii          pair<ll,ll>
#define bug(a)       cerr << #a << " : " << a << endl;
#define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

const int MAX = 1e5+10;

int main()
{
    int n,u,v;

    cin >> n;

    int in[n+2] = {};

    for(int i=1;i<n;i++)
    {
        cin >> u >> v;
        in[u]++ , in[v]++;
    }

    int cnt = 0;

    for(int i=1;i<=n;i++)
    {
        if(in[i] == 2)
        {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


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

#define ll           long long
#define pii          pair<ll,ll>
#define bug(a)       cerr << #a << " : " << a << endl;
#define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

const int MAX = 1e5+10;

int main()
{
    int n,u,v;

    cin >> n;

    int in[n+2];

    for(int i=1;i<n;i++)
    {
        cin >> u >> v;
        in[u]++ , in[v]++;
    }

    int cnt = 0;

    for(int i=1;i<=n;i++)
    {
        if(in[i] == 2)
        {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


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

#define ll           long long
#define pii          pair<ll,ll>
#define bug(a)       cerr << #a << " : " << a << endl;
#define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

const int MAX = 1e5+10;

vector<int>adj[MAX];

void DFS(int src,int par)
{
}

int main()
{
    int n,u,v;

    cin >> n;

    for(int i=1;i<n;i++)
    {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int cnt = 0;

    for(int i=1;i<=n;i++)
    {
        if(adj[i].size() == 2)
            cnt++;
    }

    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    ////////////// IGNORE THIS SOLUTION
    if(cnt)
        cout << "NO\n";
    else
        cout << "YES\n";
}


/*********************
*  Author: xuziyuan  *
*********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,x,y,sons[100010],all;
vector <int> g[100010];

int dfs(int pos,int no)
{
	rep(i,g[pos].size()) if(g[pos][i]!=no) sons[pos]+=dfs(g[pos][i],pos);
	return sons[pos]+(g[pos].size()==1 ? 1:0);
}

void dfs2(int pos,int no)
{
	rep(i,g[pos].size())
	{
		if(g[pos][i]==no) continue;
		if(sons[g[pos][i]]==1||all-sons[g[pos][i]]-(g[pos].size()==1 ? 1:0)-(g[g[pos][i]].size()==1 ? 1:0)==1)
		{
			puts("NO");
			exit(0);
		}
		dfs2(g[pos][i],pos);
	}
}

int main()
{
	cin>>n;
	rep(i,n-1)
	{
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1,0);
	all=sons[1]+(g[1].size()==1 ? 1:0);
	dfs2(1,0);
	puts("YES");
	rt0;
}


/*********************
*  Author: xuziyuan  *
*********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,x,y;
vector <int> g[100010];

int main()
{
	cin>>n;
	rep(i,n-1)
	{
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	repn(i,n)
	{
		if(g[i].size()==2)
		{
			puts("NO");
			rt0;
		}
	}
	puts("YES");
	rt0;
}


/*********************
*  Author: xuziyuan  *
*********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,x,y,sons[100010];
vector <int> g[100010];

int dfs(int pos,int no)
{
	rep(i,g[pos].size()) if(g[pos][i]!=no) sons[pos]+=dfs(g[pos][i],pos);
	return sons[pos]+(g[pos].size()==1 ? 1:0);
}

void dfs2(int pos,int no)
{
	rep(i,g[pos].size())
	{
		if(g[pos][i]==no) continue;
		if(sons[g[pos][i]]==1||n-sons[g[pos][i]]-(g[pos].size()==1 ? 1:0)-(g[g[pos][i]].size()==1 ? 1:0)==1)
		{
			puts("NO");
			exit(0);
		}
		dfs(g[pos][i],pos);
	}
}

int main()
{
	cin>>n;
	rep(i,n-1)
	{
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1,0);
	dfs2(1,0);
	puts("YES");
	rt0;
}


/*********************
*  Author: xuziyuan  *
*********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,x,y,sons[100010],all;
vector <int> g[100010];

int dfs(int pos,int no)
{
	rep(i,g[pos].size()) if(g[pos][i]!=no) sons[pos]+=dfs(g[pos][i],pos);
	return sons[pos]+(g[pos].size()==1 ? 1:0);
}

void dfs2(int pos,int no)
{
	rep(i,g[pos].size())
	{
		if(g[pos][i]==no) continue;
		if(sons[g[pos][i]]==1||all-sons[g[pos][i]]-(g[pos].size()==1 ? 1:0)-(g[g[pos][i]].size()==1 ? 1:0)==1)
		{
			puts("NO");
			exit(0);
		}
		dfs(g[pos][i],pos);
	}
}

int main()
{
	cin>>n;
	rep(i,n-1)
	{
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1,0);
	all=sons[1]+(g[1].size()==1 ? 1:0);
	dfs2(1,0);
	puts("YES");
	rt0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

// template starts
using namespace __gnu_pbds; //required
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// ordered_set <int> s;
// s.find_by_order(k); returns the (k+1)th smallest element
// s.order_of_key(k); returns the number of elements in s strictly less than k

#define MOD            (1000000000+7) // change as required
#define pb(x)          push_back(x)
#define mp(x,y)        make_pair(x,y)
#define all(x)         x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define input(vec,N)   for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x)       cerr << #x << " = " << (x) << endl;

typedef long long int ll;

// start of highly risky #defines

#define int ll // disable when you want to make code a bit faster
#define endl '\n' // disable when dealing with interactive problems

// End of highly risky #defines

// template ends here
int N;
vector<vector<int>> adj;
vector<int> dp;
bool ok = true;

void dfs(int cur, int par){
	// debug(cur)
	if(adj[cur].size() == 1 && adj[cur][0] == par){
		dp[cur] = 1;
		return;
	}

	for(auto ne: adj[cur]){
		if(ne == par) continue;
		dfs(ne,cur);
		dp[cur] += dp[ne];
	}
	if(dp[cur] == dp[par]) ok = false;
}

void solve(){
	// code starts from here
	cin >> N;
	adj.resize(N);
	for(int i = 0; i < N-1; i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	if(N <= 2){
		cout << "YES" << endl;
		return;
	}
	if(N == 3){
		cout << "NO" << endl;
		return;
	}
	int head = 0;
	for(int i = 0; i < N; i++){
		if(adj[i].size() > 1)head = i;
	}

	ok = true;
	for(int i = 0; i < N; i++){
		int leaf = 0;
		if(adj[i].size() == 1) continue;
		for(auto ne: adj[i]){
			if(adj[ne].size() == 1) leaf++;
		}
		if(leaf <= 1) ok = false;
	}
	cout << (ok?"YES":"NO") << endl;
	// cout << 2 << endl;
}

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

signed main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//startTime = clock();

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	int T;
	// cin >> T;
	T = 1;
	while(T--){
		solve();
	}

	//cout << getCurrentTime() << endl;
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

// template starts
using namespace __gnu_pbds; //required
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// ordered_set <int> s;
// s.find_by_order(k); returns the (k+1)th smallest element
// s.order_of_key(k); returns the number of elements in s strictly less than k

#define MOD            (1000000000+7) // change as required
#define pb(x)          push_back(x)
#define mp(x,y)        make_pair(x,y)
#define all(x)         x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define input(vec,N)   for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x)       cerr << #x << " = " << (x) << endl;

typedef long long int ll;

// start of highly risky #defines

#define int ll // disable when you want to make code a bit faster
#define endl '\n' // disable when dealing with interactive problems

// End of highly risky #defines

// template ends here
int N;
vector<vector<int>> adj;
vector<int> dp;
bool ok = true;

void dfs(int cur, int par){
	// debug(cur)
	if(adj[cur].size() == 1 && adj[cur][0] == par){
		dp[cur] = 1;
		return;
	}

	for(auto ne: adj[cur]){
		if(ne == par) continue;
		dfs(ne,cur);
		dp[cur] += dp[ne];
	}
	if(dp[cur] == dp[par]) ok = false;
}

void solve(){
	// code starts from here
	cin >> N;
	adj.resize(N);
	for(int i = 0; i < N-1; i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	if(N <= 2){
		cout << "YES" << endl;
		return;
	}
	if(N == 3){
		cout << "NO" << endl;
		return;
	}
	int head = 0;
	for(int i = 0; i < N; i++){
		if(adj[i].size() > 1)head = i;
	}

	ok = true;
	for(int i = 0; i < N; i++){
		if(adj[i].size() == 2) ok = false;
	}
	cout << (ok?"YES":"NO") << endl;
	// cout << 2 << endl;
}

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

signed main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//startTime = clock();

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	int T;
	// cin >> T;
	T = 1;
	while(T--){
		solve();
	}

	//cout << getCurrentTime() << endl;
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

// template starts
using namespace __gnu_pbds; //required
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// ordered_set <int> s;
// s.find_by_order(k); returns the (k+1)th smallest element
// s.order_of_key(k); returns the number of elements in s strictly less than k

#define MOD            (1000000000+7) // change as required
#define pb(x)          push_back(x)
#define mp(x,y)        make_pair(x,y)
#define all(x)         x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define input(vec,N)   for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x)       cerr << #x << " = " << (x) << endl;

typedef long long int ll;

// start of highly risky #defines

#define int ll // disable when you want to make code a bit faster
#define endl '\n' // disable when dealing with interactive problems

// End of highly risky #defines

// template ends here
int N;
vector<vector<int>> adj;
vector<int> dp;
bool ok = true;

void dfs(int cur, int par){
	// debug(cur)
	if(adj[cur].size() == 1 && adj[cur][0] == par){
		dp[cur] = 1;
		return;
	}

	for(auto ne: adj[cur]){
		if(ne == par) continue;
		dfs(ne,cur);
		dp[cur] += dp[ne];
	}
	if(dp[cur] == dp[par]) ok = false;
}

void solve(){
	// code starts from here
	cin >> N;
	adj.resize(N);
	for(int i = 0; i < N-1; i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	if(N <= 2){
		cout << "YES" << endl;
		return;
	}
	if(N == 3){
		cout << "NO" << endl;
		return;
	}
	int head = 0;
	for(int i = 0; i < N; i++){
		if(adj[i].size() > 1)head = i;
	}

	dp.resize(N);
	dfs(head,head);

	ok = true;
	for(int i = 0; i < N; i++){
		if(adj[i].size() != 2) continue;
		int leaf = (adj[adj[i][0]].size() == 1) + (adj[adj[i][1]].size() == 1);
		if(leaf == 1) ok = false;
	}
	cout << (ok?"YES":"NO") << endl;
	// cout << 2 << endl;
}

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

signed main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//startTime = clock();

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	int T;
	// cin >> T;
	T = 1;
	while(T--){
		solve();
	}

	//cout << getCurrentTime() << endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAX_N=1e5+10;
vector<int> G[MAX_N];

int main(){
	int n,x,y;
	std::cin>>n;
	for(int i=1;i<n;i++){
		std::cin>>x>>y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	for(int i=1;i<=n;i++){
		if(G[i].size()>1){
			int cnt=0;
			for(auto a:G[i]){
				cnt+=(G[a].size()==1);
			}
			if(cnt<2){
				puts("NO");
				return 0;
			}
		}
	}
	puts("YES");
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAX_N=1e5+10;
vector<int> G[MAX_N];

int main(){
	int n,x,y;
	std::cin>>n;
	for(int i=1;i<n;i++){
		std::cin>>x>>y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	for(int i=1;i<=n;i++){
		if(G[i].size()>1){
			int cnt=0;
			bool flag=false;
			for(auto a:G[i]){
				cnt+=(G[a].size()==1);
				flag|=(G[a].size()>1);
			}
			if(cnt<2||(!flag&&cnt<3)){
				puts("NO");
				return 0;
			}
		}
	}
	puts("YES");
	return 0;
}