n=int(input()) ab=[list(map(int,input().split())) for _ in range(n-1)] ki=[[] for _ in range(n)] for a,b in ab: a,b=a-1,b-1 ki[a].append(b) ki[b].append(a) deg1=[v for v in range(n) if len(ki[v])==1] v0=deg1[0] from collections import deque todo=deque([v0]) seen=[-1]*n seen[v0]=0 while todo: v=todo.popleft() for nv in ki[v]: if seen[nv]==-1: seen[nv]=seen[v]+1 todo.append(nv) v1=v todo=deque([v1]) seen=[-1]*n seen[v1]=0 while todo: v=todo.popleft() for nv in ki[v]: if seen[nv]==-1: seen[nv]=v todo.append(nv) v2=v dary=[v2] while dary[-1]!=v1: dary.append(seen[dary[-1]]) d=len(dary) if d%2==1: vm=dary[d//2] if n==1+len(ki[vm])*(d//2): print('Yes') else: print('No') else: if n==len(dary): print('Yes') else: print('No')