import collections N = int(input()) lsg = [[] for i in range(N)] lsj = [0]*(N) for i in range(N-1): a,b = map(int, input().split()) a -= 1 b -= 1 lsg[a].append(b) lsg[b].append(a) lsj[a] += 1 lsj[b] += 1 n1 = 0 n2 = 0 n3 = 0 for i in range(N): if lsj[i] == 1: n1 += 1 elif lsj[i] == 2: n2 += 1 else: n3 += 1 if n1 == 2 and n2 == N-2: #直線 print('Yes') exit() if n3 >= 2: #分岐が複数× print('No') exit() root = 0 for i in range(N): if lsj[i] >= 3: root = i break d = collections.deque([root]) used = [False]*(N) lsc = [float('INF')]*(N) lsc[root] = 0 while d: n = d.popleft() if used[n]: continue used[n] = True for j in lsg[n]: if used[j]: continue if lsc[j] > lsc[n] + 1: lsc[j] = lsc[n] + 1 d.append(j) ll = [] for i in range(N): if lsj[i] == 1: ll.append(lsc[i]) cnt = len(collections.Counter(ll).keys()) if cnt == 1: print('Yes') else: print('No')