#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > conf[25];
int n, c[25];
bool used[25];
void ready(int now, int left, int idx, int *arr, int mn) {
  if (left == 0) {
    if (idx > 1) {
      vector<int> tmpvc;
      for (int i = 0; i < idx; ++i) tmpvc.push_back(arr[i]);
      conf[now].push_back(tmpvc);
    }
    return;
  }
  for (int j = mn; j <= left; ++j) {
    if (j == 2) continue;
    arr[idx] = j;
    ready(now, left - j, idx + 1, arr, j);
  }
}
bool all_one(vector<int> &state) {
  for (int i = 0; i < state.size(); ++i)
    if (state[i] != 1) return false;
  return true;
}
bool find_pos(vector<int> &conf, vector<int> &pos) {
  bool tmpused[25];
  for (int i = 0; i < n; ++i) tmpused[i] = false;
  for (int i = 0; i < conf.size(); ++i) {
    bool found = false;
    for (int j = 0; j < n; ++j) {
      if (c[j] == conf[i] && !used[j] && !tmpused[j]) {
        found = true;
        tmpused[j] = true;
        pos.push_back(j);
        break;
      }
    }
    if (!found) return false;
  }
  return true;
}
bool check(vector<int> &state) {
  if (all_one(state)) return true;
  for (int i = 0; i < state.size(); ++i) {
    int x = state[i];
    if (x == 1) continue;
    for (int j = 0; j < conf[x].size(); ++j) {
      vector<int> tmpconf = conf[x][j];
      vector<int> position;
      if (!find_pos(tmpconf, position)) continue;
      for (int k = 0; k < position.size(); ++k) used[position[k]] = true;
      vector<int> new_state(state);
      new_state.erase(new_state.begin() + i);
      new_state.insert(new_state.begin() + i, tmpconf.begin(), tmpconf.end());
      if (check(new_state)) return true;
      for (int k = 0; k < position.size(); ++k) used[position[k]] = false;
    }
  }
  return false;
}
int main() {
  int p[25];
  for (int i = 3; i <= 24; ++i) {
    ready(i, i - 1, 0, p, 1);
  }
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", &c[i]);
      used[i] = false;
    }
    int mx = 0;
    for (int i = 1; i < n; ++i)
      if (c[i] > c[mx]) mx = i;
    vector<int> root;
    root.push_back(c[mx]);
    if (c[mx] == n && check(root))
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

Iahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve it, otherwise Iahub won't give her the food. 

Iahub asks Iahubina: can you build a rooted tree, such that

  * each internal node (a node with at least one son) has at least two sons; 
  * node i has ci nodes in its subtree? 



Iahubina has to guess the tree. Being a smart girl, she realized that it's possible no tree can follow Iahub's restrictions. In this way, Iahub will eat all the food. You need to help Iahubina: determine if there's at least one tree following Iahub's restrictions. The required tree must contain n nodes.

Input

The first line of the input contains integer n (1 ≤ n ≤ 24). Next line contains n positive integers: the i-th number represents ci (1 ≤ ci ≤ n).

Output

Output on the first line "YES" (without quotes) if there exist at least one tree following Iahub's restrictions, otherwise output "NO" (without quotes). 

Examples

Input

4
1 1 1 4


Output

YES

Input

5
1 1 5 2 1


Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > conf[25];
int n, c[25];
bool used[25];
void ready(int now, int left, int idx, int *arr, int mn) {
  if (left == 0) {
    if (idx > 1) {
      vector<int> tmpvc;
      for (int i = 0; i < idx; ++i) tmpvc.push_back(arr[i]);
      conf[now].push_back(tmpvc);
    }
    return;
  }
  for (int j = mn; j <= left; ++j) {
    if (j == 2) continue;
    arr[idx] = j;
    ready(now, left - j, idx + 1, arr, j);
  }
}
bool all_one(vector<int> &state) {
  for (int i = 0; i < state.size(); ++i)
    if (state[i] != 1) return false;
  return true;
}
bool find_pos(vector<int> &conf, vector<int> &pos) {
  bool tmpused[25];
  for (int i = 0; i < n; ++i) tmpused[i] = false;
  for (int i = 0; i < conf.size(); ++i) {
    bool found = false;
    for (int j = 0; j < n; ++j) {
      if (c[j] == conf[i] && !used[j] && !tmpused[j]) {
        found = true;
        tmpused[j] = true;
        pos.push_back(j);
        break;
      }
    }
    if (!found) return false;
  }
  return true;
}
bool check(vector<int> &state) {
  if (all_one(state)) return true;
  for (int i = 0; i < state.size(); ++i) {
    int x = state[i];
    if (x == 1) continue;
    for (int j = 0; j < conf[x].size(); ++j) {
      vector<int> tmpconf = conf[x][j];
      vector<int> position;
      if (!find_pos(tmpconf, position)) continue;
      for (int k = 0; k < position.size(); ++k) used[position[k]] = true;
      vector<int> new_state(state);
      new_state.erase(new_state.begin() + i);
      new_state.insert(new_state.begin() + i, tmpconf.begin(), tmpconf.end());
      if (check(new_state)) return true;
      for (int k = 0; k < position.size(); ++k) used[position[k]] = false;
    }
  }
  return false;
}
int main() {
  int p[25];
  for (int i = 3; i <= 24; ++i) {
    ready(i, i - 1, 0, p, 1);
  }
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", &c[i]);
      used[i] = false;
    }
    int mx = 0;
    for (int i = 1; i < n; ++i)
      if (c[i] > c[mx]) mx = i;
    vector<int> root;
    root.push_back(c[mx]);
    if (c[mx] == n && check(root))
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}

```