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) if n == 2: print('Yes') exit() s = [] s.append(0) parent = [-1]*n order = [] while s: v = s.pop() order.append(v) for u in g[v]: if parent[v] == u: continue s.append(u) parent[u] = v #print(order) order.reverse() C = [1]*n for v in order: if parent[v] != -1: C[parent[v]] += C[v] #print(C) G = [] for v in order: for u in g[v]: if parent[v] == u: continue if C[u] > n//2: break else: if n-C[v] <= n//2: G.append(v) #print(G) L = [] for v in order: if len(g[v]) == 1: L.append(v) #print(L) if len(L) == 2: print('Yes') exit() if len(G) == 2: print('No') exit() s = G[0] #print(s) 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')