N = int(input()) P = [0] * N Edge = [] for _ in range(N-1): v, u = map(int, input().split()) P[v-1] += 1 P[u-1] += 1 Edge.append((v-1, u-1)) Edge.append((u-1, v-1)) S = [k for k, v in enumerate(P) if v == 1] def getPath(s, i): global N, P, S D = [float('inf')] * N D[s] = 0 while True: update = False for f, t in Edge: if D[f] != float('inf') and D[t] > D[f] + 1: D[t] = D[f] + 1 update = True if not update: break res = -1 for e in S[i+1:]: if res < 0: res = D[e] elif res != D[e]: return -1 return res res = -1 for i, s in enumerate(S[:-1]): v = getPath(s, i) if v < 0: print('No') break elif res < 0: res = v elif res != v: print('No') break else: print('Yes')