from collections import defaultdict, deque def main(): def BFS(s): dist = [-1]*n q = deque([]) q.append(s) dist[s] = 0 while q: now = q.popleft() for to in d[now]: if dist[to] == -1: dist[to] = dist[now] + 1 q.append(to) return dist n = int(input()) d = defaultdict(list) for i in range(n-1): a, b = map(int, input().split()) a -= 1 b -= 1 d[a].append(b) d[b].append(a) ends = [] center = -1 for i in range(n): if len(d[i]) == 1: ends.append(i) elif len(d[i]) >= 3: if center == -1: center = i else: return False if center == -1: return True length = -1 dist = BFS(center) for end in ends: if length == -1: length = dist[end] elif length != dist[end]: return False return True if main(): print("Yes") else: print("No")