n = int(input()) deg = [0] * n to = [[] for _ in range(n)] for _ in range(n - 1): a, b = map(int, input().split()) a -= 1 b -= 1 to[a].append(b) to[b].append(a) deg[a] += 1 deg[b] += 1 imx = max(range(n), key=lambda i: deg[i]) if deg[imx] == 2: print('Yes') exit() if any(i != imx and deg[i] >= 3 for i in range(n)): print('No') exit() depth = [0] * n def dfs(u, p=-1): if p >= 0: depth[u] = depth[p] + 1 for v in to[u]: if v == p: continue dfs(v, u) dfs(imx) d = -1 ok = True for i in range(n): if deg[i] == 1: if d == -1: d = depth[i] elif d != depth[i]: ok = False break ans = 'Yes' if ok else 'No' print(ans)