#include <bits/stdc++.h>
using namespace std;
bool vis[100005];
vector<long long> v[100005];
bool flag;
long long cut;
long long dfs(long long ind) {
  long long i;
  if (!vis[ind]) {
    vis[ind] = true;
    long long sz = v[ind].size();
    if (ind == cut) sz--;
    if (sz >= 3) return false;
    for (i = 0; i < v[ind].size(); i++) {
      if (dfs(v[ind][i]) == false) return false;
    }
  }
  return true;
}
int main() {
  long long i, n, x, y, c, j;
  scanf("%lld", &n);
  for (i = 1; i <= n - 1; i++) {
    scanf("%lld %lld", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (i = 1; i <= n; i++) {
    if (v[i].size() <= 2) continue;
    c = 0;
    memset(vis, false, sizeof(vis));
    vis[i] = true;
    for (j = 0; j < v[i].size(); j++) {
      cut = v[i][j];
      if (!dfs(v[i][j])) c++;
    }
    if (c >= 3) {
      printf("NO");
      return 0;
    }
  }
  printf("YES");
  return 0;
}
