#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:255000000")
bool firstout = 1;
template <class T>
T &minn(T &a, T b) {
  if (b < a) a = b;
  return a;
}
template <class T>
T &maxx(T &a, T b) {
  if (a < b) a = b;
  return a;
}
int &madd(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
int &msub(int &a, int b) {
  a -= b;
  if (a < 0) a += 1000000007;
  return a;
}
int &mmult(int &a, int b) { return a = (long long)a * b % 1000000007; }
int mdiv(long long a, long long b, long long m) {
  a = (a % m + m) % m;
  b = (b % m + m) % m;
  if (a % b == 0) return a / b;
  return (a + m * mdiv(-a, m, b)) / b;
}
int n, m, q;
int A[177147];
char D[177147][25][25];
int P[25];
char fnd(int d, int x, int m, int i) {
  char &res = D[d][x][m];
  if (res >= 0) return res;
  for (; i < n && d / P[i] % 3 == 2; ++i)
    ;
  if (i == n) return res = m == 0;
  if (d / P[i] % 3 == 0) return res = 0;
  if (x == A[i]) return res = fnd(d + P[i], 1, m, i);
  res = 0;
  int k;
  for (k = i + 1; k < n; ++k)
    if (d / P[k] % 3 == 0 && x + A[k] <= A[i] && A[k] + 1 != A[i] &&
        fnd(d + P[k], x + A[k], m, i))
      return res = 1;
  if (m >= A[i] - x) return res = fnd(d, A[i], m - (A[i] - x), i);
  return res = 0;
}
int main() {
  int i, j, k;
  char c;
  int a, d;
  P[0] = 1;
  for (i = (1); i < (25); ++i) P[i] = P[i - 1] * 3;
  int ts;
  for (ts = 1; scanf("%"
                     "d",
                     &(n)) > 0;
       ++ts) {
    for (i = (0); i < (n); ++i)
      scanf(
          "%"
          "d",
          &(A[i]));
    sort(A, A + n);
    reverse(A, A + n);
    for (i = (0); i < (n); ++i)
      if (A[i] == 1) break;
    m = n - i;
    n = i;
    bool g = 1;
    for (i = (0); i < (n); ++i)
      if (A[i] == 2) g = 0;
    if (n > 11 || !g)
      printf(
          "%"
          "s",
          ("NO")),
          printf("\n"), firstout = 1;
    else if (n + m == 1)
      printf(
          "%"
          "s",
          ("YES")),
          printf("\n"), firstout = 1;
    else {
      for (i = (0); i < (P[n]); ++i)
        for (j = (1); j < (n + m + 1); ++j)
          for (k = (0); k < (m + 1); ++k) D[i][j][k] = -1;
      int res = fnd(1, 1, m, 0);
      printf(
          "%"
          "s",
          (res ? "YES" : "NO"));
      printf("\n"), firstout = 1;
    }
  }
  return 0;
}

### Prompt

Create a solution in CPP for 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;
#pragma comment(linker, "/STACK:255000000")
bool firstout = 1;
template <class T>
T &minn(T &a, T b) {
  if (b < a) a = b;
  return a;
}
template <class T>
T &maxx(T &a, T b) {
  if (a < b) a = b;
  return a;
}
int &madd(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
int &msub(int &a, int b) {
  a -= b;
  if (a < 0) a += 1000000007;
  return a;
}
int &mmult(int &a, int b) { return a = (long long)a * b % 1000000007; }
int mdiv(long long a, long long b, long long m) {
  a = (a % m + m) % m;
  b = (b % m + m) % m;
  if (a % b == 0) return a / b;
  return (a + m * mdiv(-a, m, b)) / b;
}
int n, m, q;
int A[177147];
char D[177147][25][25];
int P[25];
char fnd(int d, int x, int m, int i) {
  char &res = D[d][x][m];
  if (res >= 0) return res;
  for (; i < n && d / P[i] % 3 == 2; ++i)
    ;
  if (i == n) return res = m == 0;
  if (d / P[i] % 3 == 0) return res = 0;
  if (x == A[i]) return res = fnd(d + P[i], 1, m, i);
  res = 0;
  int k;
  for (k = i + 1; k < n; ++k)
    if (d / P[k] % 3 == 0 && x + A[k] <= A[i] && A[k] + 1 != A[i] &&
        fnd(d + P[k], x + A[k], m, i))
      return res = 1;
  if (m >= A[i] - x) return res = fnd(d, A[i], m - (A[i] - x), i);
  return res = 0;
}
int main() {
  int i, j, k;
  char c;
  int a, d;
  P[0] = 1;
  for (i = (1); i < (25); ++i) P[i] = P[i - 1] * 3;
  int ts;
  for (ts = 1; scanf("%"
                     "d",
                     &(n)) > 0;
       ++ts) {
    for (i = (0); i < (n); ++i)
      scanf(
          "%"
          "d",
          &(A[i]));
    sort(A, A + n);
    reverse(A, A + n);
    for (i = (0); i < (n); ++i)
      if (A[i] == 1) break;
    m = n - i;
    n = i;
    bool g = 1;
    for (i = (0); i < (n); ++i)
      if (A[i] == 2) g = 0;
    if (n > 11 || !g)
      printf(
          "%"
          "s",
          ("NO")),
          printf("\n"), firstout = 1;
    else if (n + m == 1)
      printf(
          "%"
          "s",
          ("YES")),
          printf("\n"), firstout = 1;
    else {
      for (i = (0); i < (P[n]); ++i)
        for (j = (1); j < (n + m + 1); ++j)
          for (k = (0); k < (m + 1); ++k) D[i][j][k] = -1;
      int res = fnd(1, 1, m, 0);
      printf(
          "%"
          "s",
          (res ? "YES" : "NO"));
      printf("\n"), firstout = 1;
    }
  }
  return 0;
}

```