#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e+5 + 10;
vector<int> a[MAXN];
int vis[MAXN], k[MAXN];
void dfs(int v, int f) {
  if (a[v].size() <= 2) {
    vis[v] = true;
    for (auto u : a[v]) {
      if (u != f) dfs(u, v);
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0, x, y; i < n - 1; i++) {
    cin >> x >> y;
    a[--x].push_back(--y);
    a[y].push_back(x);
  }
  for (int i = 0; i < n; i++) {
    if (a[i].size() == 1) dfs(i, -1);
  }
  for (int i = 0; i < n; i++) {
    for (auto u : a[i])
      if (vis[u]) k[i] = k[i] + 1;
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      int cnt = 0;
      for (auto u : a[i]) {
        if (!vis[u] && a[u].size() - min(k[u], 2) > 1) cnt++;
      }
      if (cnt >= 3) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
