#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
int T, n, m, i, j, k, l, K, r, s, t, d, u, ii, jj, x, y, z, h[N], hh[N][20][20];
vector<pair<int, pair<int, int> > > v[N];
void g(int ii, int x, int y, int z, int t) {
  if (y >= n) {
    v[ii].push_back(make_pair(x, make_pair(z, t)));
    return;
  }
  if ((ii & (1 << y)) == 0) g(ii, x + (1 << y), y + 1, z + 1, t + h[y + 1]);
  g(ii, x, y + 1, z, t);
}
void f(int x, int y, int z) {
  if (d or z < 0 or hh[x][y][z]) return;
  if (y == n and z == 0 and x == (1 << n - 1) - 1) {
    d = 1;
    return;
  }
  if (y == n) return;
  hh[x][y][z] = 1;
  v[x].clear();
  K = 0;
  g(x, 0, 0, 0, 0);
  for (int i = 0; i < v[x].size(); i++) {
    int a = v[x][i].first, b = v[x][i].second.first, c = v[x][i].second.second;
    if (c < h[y + 1] and b + h[y + 1] - c - 1 > 1)
      f(x + a, y + 1, z - (h[y + 1] - 1 - c));
  }
}
int main() {
  {
    cin >> n;
    s = u = 0;
    for (i = 1; i <= n; i++) {
      cin >> x;
      if (x == 1)
        s++;
      else
        h[++u] = x;
    }
    sort(h + 1, h + 1 + u);
    if (n == 1 and s == 1) {
      cout << "YES\n";
      return 0;
    }
    if (n - s > 12) {
      cout << "NO\n";
      return 0;
    }
    memset(hh, 0, sizeof hh);
    d = 0;
    n -= s;
    f(0, 0, s);
    if (d)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}

### Prompt

Develop a solution in cpp to the problem described below:

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;
const int N = 5000;
int T, n, m, i, j, k, l, K, r, s, t, d, u, ii, jj, x, y, z, h[N], hh[N][20][20];
vector<pair<int, pair<int, int> > > v[N];
void g(int ii, int x, int y, int z, int t) {
  if (y >= n) {
    v[ii].push_back(make_pair(x, make_pair(z, t)));
    return;
  }
  if ((ii & (1 << y)) == 0) g(ii, x + (1 << y), y + 1, z + 1, t + h[y + 1]);
  g(ii, x, y + 1, z, t);
}
void f(int x, int y, int z) {
  if (d or z < 0 or hh[x][y][z]) return;
  if (y == n and z == 0 and x == (1 << n - 1) - 1) {
    d = 1;
    return;
  }
  if (y == n) return;
  hh[x][y][z] = 1;
  v[x].clear();
  K = 0;
  g(x, 0, 0, 0, 0);
  for (int i = 0; i < v[x].size(); i++) {
    int a = v[x][i].first, b = v[x][i].second.first, c = v[x][i].second.second;
    if (c < h[y + 1] and b + h[y + 1] - c - 1 > 1)
      f(x + a, y + 1, z - (h[y + 1] - 1 - c));
  }
}
int main() {
  {
    cin >> n;
    s = u = 0;
    for (i = 1; i <= n; i++) {
      cin >> x;
      if (x == 1)
        s++;
      else
        h[++u] = x;
    }
    sort(h + 1, h + 1 + u);
    if (n == 1 and s == 1) {
      cout << "YES\n";
      return 0;
    }
    if (n - s > 12) {
      cout << "NO\n";
      return 0;
    }
    memset(hh, 0, sizeof hh);
    d = 0;
    n -= s;
    f(0, 0, s);
    if (d)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}

```