#include <bits/stdc++.h>
using namespace std;
int tot, head[1200000], to[1200000], nx[1200000], n, gen, du[1200000];
bool vis[1200000];
void add(int a, int b) {
  tot++;
  nx[tot] = head[a];
  to[tot] = b;
  head[a] = tot;
  return;
}
int dfs(int x) {
  int sxd[10] = {0};
  bool flag = false;
  for (int i = head[x]; i; i = nx[i]) {
    int at = to[i];
    if (vis[at] == false) {
      vis[at] = true;
      sxd[dfs(at)]++;
      flag = 1;
    }
  }
  if (flag == false)
    return 1;
  else if (sxd[1] == 1 && sxd[2] == 0 && sxd[3] == 0 && sxd[4] == 0 &&
           sxd[5] == 0)
    return 1;
  else if (sxd[1] == 2 && sxd[2] == 0 && sxd[3] == 0 && sxd[4] == 0 &&
           sxd[5] == 0)
    return 2;
  else if (((sxd[1] >= 3 && sxd[3] <= 1) || (sxd[2] >= 1 && sxd[3] <= 1) ||
            sxd[3] == 1) &&
           sxd[4] == 0 && sxd[5] == 0)
    return 3;
  else if ((sxd[3] == 2 && sxd[4] == 0 && sxd[5] == 0))
    return 4;
  else
    return 5;
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    add(x, y);
    add(y, x);
    du[x]++;
    du[y]++;
  }
  for (int i = 1; i <= 50; i++) {
    memset(vis, 0, sizeof vis);
    gen = rand() % n + 1;
    vis[gen] = 1;
    if (dfs(gen) < 5) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}
