from collections import defaultdict, 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) s = [] for i in range(N): if len(G[i])==1: s.append(i) if len(s)==2: print('Yes') else: dis = [-1]*N pre = [-1]*N d = deque() d.append(s[0]) dis[s[0]] = 0 while d: v = d.popleft() for nex in G[v]: if dis[nex]==-1: dis[nex]=dis[v]+1 pre[nex] = v d.append(nex) if dis[s[1]]%2==1: exit(print('No')) else: dd = dis[s[1]]//2 nn = dis[s[1]] v = s[1] while nn>dd: v = pre[v] nn = dis[v] d.append(v) dis2 = [-1]*N dis2[v] = 0 while d: ver = d.popleft() for nex in G[ver]: if dis2[nex]==-1: dis2[nex]=dis2[ver]+1 d.append(nex) for ss in s: if dis2[ss]!=nn: print('No') exit() print('Yes')