#include <bits/stdc++.h>
using namespace std;
const int M = 5e5 + 5, LG = 25, inf = 1e9, mod = 95542721;
int n;
int c[M];
vector<int> chos[M];
void ret(string x) {
  cout << x;
  exit(0);
}
int used;
bool bt(int x) {
  if (x == -1) {
    return (used == (1 << n) - 2);
  }
  for (int msk : chos[c[x] - 1]) {
    if (msk & used) continue;
    used |= msk;
    if (bt(x - 1)) return 1;
    used -= msk;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  if (n < 3) ret(n == 1 ? "YES" : "NO");
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  sort(c, c + n, [](int a, int b) { return a > b; });
  int x;
  if (c[0] != n || c[1] == n) ret("NO");
  for (int i = n - 1; i >= 0; i--) {
    x = i;
    if (c[i] != 1) break;
  }
  if (c[x] == 2) ret("NO");
  int t = c[x];
  while (c[x] == t) {
    for (int i = 1; i < t; i++)
      if (c[n - 1] != 1) {
        ret("NO");
      } else
        n--;
    x--;
    if (x < 0) ret(n == 1 ? "YES" : "NO");
  }
  for (int msk = 0; msk < (1 << n); msk++) {
    int su = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if ((msk >> i) & 1) {
        cnt++;
        su += c[i];
      }
    }
    if (cnt < 2 || su >= c[0]) continue;
    chos[su].push_back(msk);
  }
  ret(bt(x) ? "YES" : "NO");
}

### Prompt

Please formulate a CPP solution to the following problem:

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 M = 5e5 + 5, LG = 25, inf = 1e9, mod = 95542721;
int n;
int c[M];
vector<int> chos[M];
void ret(string x) {
  cout << x;
  exit(0);
}
int used;
bool bt(int x) {
  if (x == -1) {
    return (used == (1 << n) - 2);
  }
  for (int msk : chos[c[x] - 1]) {
    if (msk & used) continue;
    used |= msk;
    if (bt(x - 1)) return 1;
    used -= msk;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  if (n < 3) ret(n == 1 ? "YES" : "NO");
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  sort(c, c + n, [](int a, int b) { return a > b; });
  int x;
  if (c[0] != n || c[1] == n) ret("NO");
  for (int i = n - 1; i >= 0; i--) {
    x = i;
    if (c[i] != 1) break;
  }
  if (c[x] == 2) ret("NO");
  int t = c[x];
  while (c[x] == t) {
    for (int i = 1; i < t; i++)
      if (c[n - 1] != 1) {
        ret("NO");
      } else
        n--;
    x--;
    if (x < 0) ret(n == 1 ? "YES" : "NO");
  }
  for (int msk = 0; msk < (1 << n); msk++) {
    int su = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if ((msk >> i) & 1) {
        cnt++;
        su += c[i];
      }
    }
    if (cnt < 2 || su >= c[0]) continue;
    chos[su].push_back(msk);
  }
  ret(bt(x) ? "YES" : "NO");
}

```