#include <bits/stdc++.h>
using namespace std;
inline void setmin(int &x, int y) {
  if (y < x) x = y;
}
inline void setmax(int &x, int y) {
  if (y > x) x = y;
}
inline void setmin(long long &x, long long y) {
  if (y < x) x = y;
}
inline void setmax(long long &x, long long y) {
  if (y > x) x = y;
}
const int N = 100000;
const int inf = (int)1e9 + 1;
const long long big = (long long)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;
vector<int> g[N];
int type[N];
void dfs(int u, int par) {
  vector<int> children;
  for (int v : g[u])
    if (v != par) {
      dfs(v, u);
      children.push_back(v);
    }
  if ((int)children.size() == 0 ||
      (int)children.size() == 1 && type[children[0]] == 0)
    type[u] = 0;
  else if ((int)children.size() == 2 && type[children[0]] == 0 &&
           type[children[1]] == 0)
    type[u] = 1;
  else {
    int cnt_bad = 0;
    for (int v : children)
      if (type[v] == 2)
        cnt_bad++;
      else if (type[v] == 3 || type[v] == 4)
        cnt_bad += 3;
    if (cnt_bad <= 1)
      type[u] = 2;
    else if (cnt_bad == 2)
      type[u] = 3;
    else
      type[u] = 4;
  }
}
void dfs1(int u, int par, int type_in) {
  vector<int> children;
  int cnt_bad = 0;
  if (type_in == 2)
    cnt_bad++;
  else if (type_in == 3 || type_in == 4)
    cnt_bad += 3;
  for (int v : g[u])
    if (v != par) {
      children.push_back(v);
      if (type[v] == 2)
        cnt_bad++;
      else if (type[v] == 3 || type[v] == 4)
        cnt_bad += 3;
    }
  if (cnt_bad <= 2) {
    cout << "Yes\n";
    exit(0);
  }
  for (int i = 0; i < (int)children.size(); i++) {
    int v = children[i];
    if (type[v] == 2)
      cnt_bad--;
    else if (type[v] == 3 || type[v] == 4)
      cnt_bad -= 3;
    if ((int)children.size() == 1 && type_in <= 0 ||
        (int)children.size() == 2 && type[children[i ^ 1]] == 0 &&
            type_in == -1)
      dfs1(v, u, 0);
    else if ((int)children.size() == 2 && type[children[i ^ 1]] == 0 &&
                 type_in == 0 ||
             (int)children.size() == 3 && type[children[(i + 1) % 3]] == 0 &&
                 type[children[(i + 2) % 3]] == 0 && type_in == -1)
      dfs1(v, u, 1);
    else {
      if (cnt_bad <= 1)
        dfs1(v, u, 2);
      else if (cnt_bad == 2)
        dfs1(v, u, 3);
      else
        dfs1(v, u, 4);
    }
    if (type[v] == 2)
      cnt_bad++;
    else if (type[v] == 3 || type[v] == 4)
      cnt_bad += 3;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0, -1);
  dfs1(0, -1, -1);
  cout << "No\n";
  return 0;
}
