N = int(input()) links = [[] for _ in range(N)] for _ in range(N - 1): a, b = map(lambda x: int(x) - 1, input().split()) links[a].append(b) links[b].append(a) a = sorted((len(l) for l in links), reverse=True) if a[0] <= 2: print('Yes') exit() elif a[1] >= 3: print('No') exit() for i in range(N): if len(links[i]) < 3: continue break root = i d = [-1] * N d[root] = 0 q = [root] while q: i = q.pop() for j in links[i]: if d[j] != -1: continue d[j] = d[i] + 1 q.append(j) for i in range(root + 1, N): if len(links[i]) != 1: continue a = d[i] break for i in range(i + 1, N): if len(links[i]) != 1: continue if d[i] == a: continue print('No') break else: print('Yes')