from collections import deque N = int(input()) G = [list() for _ in range(N)] for i in range(N-1): a, b = map(int, input().split()) a-=1;b-=1 G[a].append(b) G[b].append(a) s1, s2 = [], [] for i in range(N): if len(G[i])==1: s1.append(i) else: s2.append(i) if len(s1)==2: exit(print('Yes')) else: cnt = 0 s3 = [] for s in s2: if len(G[s])>=3: cnt += 1 s3.append(s) if cnt>1: exit(print('No')) else: d = deque([s3[0]]) dis = [-1]*N dis[s3[0]] = 0 while d: v = d.popleft() for nex in G[v]: if dis[nex]==-1: dis[nex]= dis[v]+1 d.append(nex) dd = [] for a in s1: dd.append(dis[a]) if len(set(dd))==1: print('Yes') else: print('No')