import sys from collections import deque input = sys.stdin.buffer.readline n = int(input()) graph = [[] for _ in range(n)] deg1 = [0] * n deg2 = [0] * n for _ in range(n - 1): a, b = map(int, input().split()) a, b = a - 1, b - 1 graph[a].append(b) graph[b].append(a) deg1[a] += 1 deg1[b] += 1 kouho = deque() haji = [] dist1 = [-1] * n done = [0] * n for i in range(n): if deg1[i] == 1: haji.append(i) def ok(): print("Yes") exit() def ng(): print("No") exit() if n == 2 or n == 3: ok() # bfs # print("kouho", kouho) v = haji[0] dist1[v] = 0 kouho.append(v) while kouho: v = kouho.popleft() d = dist1[v] for u in graph[v]: if dist1[u] == -1: dist1[u] = d + 1 kouho.append(u) temp = dist1[haji[1]] for v in haji[1:]: if dist1[v] != temp: ng() kouho = deque() dist2 = [-1] * n v = haji[-1] dist2[v] = 0 kouho.append(v) while kouho: v = kouho.popleft() d = dist2[v] for u in graph[v]: if dist2[u] == -1: dist2[u] = d + 1 kouho.append(u) temp = dist2[haji[0]] for v in haji[:-1]: if dist2[v] != temp: ng() ok()