from collections import Counter N = int(input()) AB = [list(map(int,input().split())) for _ in range(N-1)] D = [0] * N E = [[] for _ in range(N)] for a, b in AB: a -= 1 b -= 1 E[a].append(b) E[b].append(a) D[a] += 1 D[b] += 1 C = Counter(D) ''' 次以外の時はNO 次数1の数2で残り全部2の時 次数2の数が次数1の数の定数倍で次数が次数1の数である頂点がある ''' def check(x,x1): nv = [1] * N nv[x] = 0 Q = [x] Q2 = [] while Q: while Q: x = Q.pop() for y in E[x]: if nv[y]: nv[y] = 0 Q2.append(y) if not(len(Q2) == x1 or len(Q2) == 0): return False Q,Q2 = Q2,Q return True x1 = C[1] x2 = C[2] NC = len(C) f = False if x1 == 2: if x2 == 0: if NC == 1: f = True else: if NC == 2: f = True else: if x2 == 0: if C[x1] == 1 and NC == 2: f = True elif x2 % x1 == 0: if C[x1] == 1 and NC == 3: st = D.index(x1) f = check(st,x1) if f: print("Yes") else: print("No")