import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n = int(input()) g = [[] for i in range(n)] for i in range(n-1): a, b = map(int, input().split()) a, b = a-1, b-1 g[a].append(b) g[b].append(a) G = [] L = [] for i in range(n): if len(g[i]) >= 3: G.append(i) if len(g[i]) == 1: L.append(i) if len(G) >= 2: print('No') exit() if not G: print('Yes') exit() s = G[0] from collections import deque q = deque([]) q.append(s) dist = [-1]*n dist[s] = 0 while q: v = q.popleft() for u in g[v]: if dist[u] == -1: dist[u] = dist[v]+1 q.append(u) D = set() for l in L: D.add(dist[l]) #print(D) if len(D) == 1: print('Yes') else: print('No')