#include <bits/stdc++.h>
using namespace std;
vector<int> edges[200004];
int deg[200004];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
    deg[b]++;
    deg[a]++;
  }
  set<int> s;
  for (int i = 1; i <= n; i++) {
    if (deg[i] == 1) s.insert(i);
  }
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    if (s.find(i) == s.end()) {
      int count = 0;
      for (int x : edges[i]) {
        count++;
      }
      if (count <= 2) {
        flag = 1;
      }
    }
  }
  if (flag) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
}
