import sys def input(): return sys.stdin.buffer.readline()[:-1] n = int(input()) adj = [[] for _ in range(n)] for _ in range(n-1): a, b = map(int, input().split()) adj[a-1].append(b-1) adj[b-1].append(a-1) for i in range(n): if len(adj[i]) == 1: leaf = i break depth = [1000000 for _ in range(n)] depth[leaf] = 0 st = [(leaf, -1)] while st: i, p = st.pop() if len(adj[i]) == 1 and i != leaf: other = i break for j in adj[i]: if j == p: continue else: depth[j] = depth[i] + 1 st.append((j, i)) if depth[other] % 2 == 1: print("Yes" if max(len(adj[i]) <= 2 for i in range(n)) else "No") sys.exit() for i in range(n): if depth[i] == depth[other] // 2: center = i assumed = depth[i] break depth = [1000000 for _ in range(n)] depth[center] = 0 st = [(center, -1)] while st: i, p = st.pop() if len(adj[i]) == 1 and depth[i] != assumed: print("No") break for j in adj[i]: if j == p: continue else: depth[j] = depth[i] + 1 st.append((j, i)) else: for i in range(n): if i != center and len(adj[i]) > 2: print("No") break else: print("Yes")