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)] 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[a].append(b) g[b].append(a) if n == 2: print('Yes') exit() from collections import deque q = deque([]) leaf = [] for v in range(n): if len(g[v]) == 1: q.append(v) leaf.append(v) if len(q) == 2: print('Yes') exit() N = n while N > 2: l = len(q) N -= l for i in range(l): v = q.popleft() for u in g[v]: g[u].remove(v) if len(g[u]) == 1: q.append(u) #print(list(q)) if len(q) >= 2: print('No') exit() s = q[0] #print(s) q = deque([]) q.append(s) dist = [-1]*len(g) 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 leaf: D.add(dist[l]) if len(D) == 1: print('Yes') else: print('No')