import sys input = sys.stdin.readline N = int(input()) e = [[] for _ in range(N + 1)] inc = [0] * (N + 1) for _ in range(N - 1): u, v = map(int, input().split()) e[u].append(v) e[v].append(u) inc[u] += 1 inc[v] += 1 if max(inc) <= 2: print("Yes") exit(0) root = 1 for x in range(1, N + 1): if inc[root] < inc[x]: root = x s = [root] vis = [0] * (N + 1) vis[root] = 1 depth = [0] * (N + 1) while len(s): x = s.pop() for y in e[x]: if vis[y]: continue vis[y] = 1 s.append(y) if inc[y] > 2: print("No") exit(0) depth[y] = depth[x] + 1 leaves = [] for x in range(1, N + 1): if inc[x] == 1: leaves.append(depth[x]) if len(set(leaves)) == 1: print("Yes") else: print("No")