#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#define DN 200005
#define LL long long
#define x first
#define y second
using namespace std;
typedef pair<int,int> per;
typedef vector<int>::iterator it;
int n,d[DN],pre[DN],inc[DN];
vector<int> gr[DN];
bitset<DN> viz;
void dfs(int s) {//Search for the longest chain in a tree
//cout<<s<<": ";
for(it i=gr[s].begin(); i!=gr[s].end(); ++i) {
//cout<<*i<<' '<<d[*i]<<' ';
if(!d[*i]) {
d[*i]=1+d[s];
pre[*i]=s;
dfs(*i);
}
}
//cout<<'\n';
}
int ich(int s) {//returns 1 if there's a chain starting in node s
viz[s]=1;
if(gr[s].size()>2) return 0;
for(it i=gr[s].begin(); i!=gr[s].end(); ++i) if(!viz[*i]) return ich(*i);
return 1;
}
int one_row(int s) {//returns 1 if starting from node s all sons can be put on one line
if(gr[s].size()>3) return 0;
viz[s]=1;
int ok=1;
for(it i=gr[s].begin(); i!=gr[s].end(); ++i) if(!inc[*i]) ok&=ich(*i);
return ok;
}
int main() {
//freopen("input.txt","r",stdin);
cin.sync_with_stdio(false);
cin>>n;
if(n==1) {
cout<<"Yes";
return 0;
}
for(int i=1; i<n; ++i) {
int a,b; cin>>a>>b;
gr[a].push_back(b);
gr[b].push_back(a);
}
d[1]=1;
dfs(1);
int n1,dm=0;
for(int i=1; i<=n; ++i) if(d[i]>dm) {
dm=d[i];
n1=i;
}
for(int i=1; i<=n; ++i) d[i]=0;
d[n1]=1;
dfs(n1);
int n2;dm=0;
for(int i=1; i<=n; ++i) if(i!=n1 && d[i]>dm) {
dm=d[i];
n2=i;
}
//n1 n2 ends of the longest chain
inc[n1]=viz[n1]=1;
for(;n2!=n1; n2=pre[n2]) inc[n2]=viz[n2]=1;
string r="Yes";
for(int i=1; i<=n; ++i) if(inc[i]) {
int ok=1;
for(it j=gr[i].begin(); j!=gr[i].end(); ++j) if(!inc[*j] && !one_row(*j)) {
ok=0;
//cout<<i<<' '<<*j<<'\n';
break;
}
if(!ok) {
r="No\n";
break;
}
}
cout<<r;
}