#include <bits/stdc++.h>
using namespace std;
int const N = 24 + 2;
int n;
int size[N];
vector<int> node;
int sum[(1 << 13) + 37];
bool dp[N][(1 << 13) + 37][N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", size + i);
  }
  if (n == 1) {
    if (size[n] == 1) {
      puts("YES");
    } else {
      puts("NO");
    }
  } else {
    int leaves = 0;
    for (int i = 1; i <= n; ++i) {
      if (size[i] == 1) {
        leaves++;
      } else {
        node.push_back(size[i]);
      }
    }
    sort(node.begin(), node.end());
    int nodes = (int)node.size();
    if (nodes > 13) {
      puts("NO");
    } else {
      int all = (1 << nodes) - 1;
      for (int mask = 0; mask <= all; ++mask) {
        for (int i = 0; i < nodes; ++i) {
          if ((mask >> i) & 1) {
            sum[mask] += node[i];
          }
        }
      }
      dp[0][0][leaves] = true;
      for (int i = 0; i < nodes; ++i) {
        for (int mask = 0; mask <= all; ++mask) {
          for (int j = 0; j <= leaves; ++j) {
            if (dp[i][mask][j]) {
              int rest = (all ^ mask) & ((1 << i) - 1);
              for (int choose = rest; choose > 0;
                   choose = (choose - 1) & rest) {
                if (sum[choose] + 1 <= node[i]) {
                  int need = node[i] - sum[choose] - 1;
                  if (need <= j && need + __builtin_popcount(choose) >= 2) {
                    dp[i + 1][choose ^ mask][j - need] = true;
                  }
                }
              }
              int need = node[i] - 1;
              if (need <= j && need >= 2) {
                dp[i + 1][mask][j - need] |= dp[i][mask][j];
              }
            }
          }
        }
      }
      bool satisfied = dp[nodes][all ^ (1 << nodes - 1)][0];
      if (satisfied) {
        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;
int const N = 24 + 2;
int n;
int size[N];
vector<int> node;
int sum[(1 << 13) + 37];
bool dp[N][(1 << 13) + 37][N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", size + i);
  }
  if (n == 1) {
    if (size[n] == 1) {
      puts("YES");
    } else {
      puts("NO");
    }
  } else {
    int leaves = 0;
    for (int i = 1; i <= n; ++i) {
      if (size[i] == 1) {
        leaves++;
      } else {
        node.push_back(size[i]);
      }
    }
    sort(node.begin(), node.end());
    int nodes = (int)node.size();
    if (nodes > 13) {
      puts("NO");
    } else {
      int all = (1 << nodes) - 1;
      for (int mask = 0; mask <= all; ++mask) {
        for (int i = 0; i < nodes; ++i) {
          if ((mask >> i) & 1) {
            sum[mask] += node[i];
          }
        }
      }
      dp[0][0][leaves] = true;
      for (int i = 0; i < nodes; ++i) {
        for (int mask = 0; mask <= all; ++mask) {
          for (int j = 0; j <= leaves; ++j) {
            if (dp[i][mask][j]) {
              int rest = (all ^ mask) & ((1 << i) - 1);
              for (int choose = rest; choose > 0;
                   choose = (choose - 1) & rest) {
                if (sum[choose] + 1 <= node[i]) {
                  int need = node[i] - sum[choose] - 1;
                  if (need <= j && need + __builtin_popcount(choose) >= 2) {
                    dp[i + 1][choose ^ mask][j - need] = true;
                  }
                }
              }
              int need = node[i] - 1;
              if (need <= j && need >= 2) {
                dp[i + 1][mask][j - need] |= dp[i][mask][j];
              }
            }
          }
        }
      }
      bool satisfied = dp[nodes][all ^ (1 << nodes - 1)][0];
      if (satisfied) {
        puts("YES");
      } else {
        puts("NO");
      }
    }
  }
  return 0;
}

```