using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); static int[] LList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => int.Parse(ReadLine())).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var map = NArr(n - 1); var tree = new List[n]; for (var i = 0; i < tree.Length; ++i) tree[i] = new List(); foreach (var edge in map) { tree[edge[0] - 1].Add(edge[1] - 1); tree[edge[1] - 1].Add(edge[0] - 1); } var hasBranch = false; for (var i = 0; i < n; ++i) { if (tree[i].Count > 2) { if (hasBranch) { WriteLine("No"); return; } hasBranch = true; var dep = new int[n]; DFS(i, -1, tree, dep); var len = -1; for (var j = 0; j < n; ++j) if (tree[j].Count == 1) { if (len < 0) { len = dep[j]; } else if (len != dep[j]) { WriteLine("No"); return; } } } } WriteLine("Yes"); } static void DFS(int cur, int prev, List[] tree, int[] dep) { foreach (var next in tree[cur]) { if (prev == next) continue; dep[next] = dep[cur] + 1; DFS(next, cur, tree, dep); } } }