import sys input = sys.stdin.readline N=int(input()) E=[[] for i in range(N)] ED=[0]*N for i in range(N-1): x,y=map(int,input().split()) E[x-1].append(y-1) E[y-1].append(x-1) ED[x-1]+=1 ED[y-1]+=1 root=-1 for i in range(N): if ED[i]==1: if root==-1: Q=[i] root=i else: root2=i Q2=[i] L=[0]*N while Q: x=Q.pop() for to in E[x]: if L[to]==0: L[to]=L[x]+1 Q.append(to) L2=[0]*N while Q2: x=Q2.pop() for to in E[x]: if L2[to]==0: L2[to]=L2[x]+1 Q2.append(to) flag=1 MAX=max(L) MAX2=max(L2) if MAX!=MAX2: print("No") exit() for i in range(N): if ED[i]==1: if L[i]==MAX or i==root: True else: print("No") exit() for i in range(N): if ED[i]==1: if L2[i]==MAX2 or i==root2: True else: print("No") exit() print("Yes")