#include <bits/stdc++.h>
using namespace std;
bool helper(long long ind, long long par, vector<vector<long long>> &adj,
            long long &val) {
  bool in = false;
  for (auto i : adj[ind]) {
    if (i != par) {
      in = true;
      if (helper(i, ind, adj, val)) return true;
    }
  }
  if (adj[ind].size() == 2) return true;
  return false;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<vector<long long>> adj(n + 1);
  for (int i = 0; i < n - 1; i++) {
    long long u, vector;
    cin >> u >> vector;
    adj[u].push_back(vector);
    adj[vector].push_back(u);
  }
  long long val = 0;
  bool ans = helper(1, -1, adj, val);
  if (n == 2) ans = false;
  if (ans)
    cout << "NO";
  else
    cout << "YES";
}
