from collections import deque n = int(input()) e = [[] for i in range(n)] for i in range(n-1): a,b = map(int,input().split()) a -= 1 b -= 1 e[a].append(b) e[b].append(a) cand = [] for i in range(n): if len(e[i]) == 1: cand.append(i) def search(ind): dis = [10**10]*n dis[cand[ind]] = 0 q = deque([cand[ind]]) while q: now = q.popleft() for nex in e[now]: if dis[nex] > dis[now]+1: dis[nex] = dis[now]+1 q.append(nex) num = dis[cand[(ind+1)%len(cand)]] for i in cand: if i != cand[ind] and num != dis[i]: print("No") exit() search(0) search(1) print("Yes")