#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
int dfs(int curr, int prev = -1) {
  int res = 0, cnt = 0;
  for (int next : adj[curr]) {
    if (next != prev) {
      ++cnt;
      res += dfs(next, curr);
    }
  }
  if (prev != -1 && cnt == 1) return 1;
  return res > 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  adj.resize(n + 1);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int curr = 1, prev = 0, end = 0;
  while (!end) {
    end = 1;
    for (int next : adj[curr]) {
      if (next != prev) {
        end = 0;
        prev = curr;
        curr = next;
        break;
      }
    }
  }
  if (dfs(curr))
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
