#include <bits/stdc++.h>

using namespace std;

typedef long long int64;

char dp[1 << 26];

inline int tapris(int bit)
{
  return (dp[bit]);
}

int N, A[5];
int latte[10];
int malta[5];

int main()
{
  memset(dp, -1, sizeof(dp));
  for(int i = 0; i < 1 << 26; i++) dp[i] = __builtin_popcount(i);

  cin >> N;

  int64 sum = 0LL;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }

  int proc = 0;
  for(int i = 0; i < 1 << 5; i++) {
    if(tapris(i) <= 1) continue;
    int ei = 0;
    for(int j = 0; j < 5; j++) {
      for(int k = j + 1; k < 5; k++) {
        if((i >> j) & 1 && (i >> k) & 1) {
          latte[ei] |= 1 << proc;
        }
        ei++;
      }
    }
    for(int j = 0; j < 5; j++) {
      if((i >> j) & 1) malta[j] |= 1 << proc;
    }
    ++proc;
  }

  int64 ret = 0;
  for(int i = 0; i < 1 << proc; i++) {
    bool iz = true;
    for(int j = 0; j < 10; j++) {
      iz &= tapris(i & latte[j]) <= 1;
    }
    int64 beet = 0LL;
    for(int j = 0; j < 5; j++) {
      int get = tapris(i & malta[j]);
      iz &= get <= A[j];
      beet += get;
    }
    if(iz) ret = max(ret, beet - tapris(i));
  }

  cout << sum - ret << endl;

}
### Prompt

Your challenge is to write a CPP solution to the following problem:

There is a complete graph of m vertices. Initially, the edges of the complete graph are uncolored. Sunuke did the following for each i (1 ≤ i ≤ n): Select ai vertices from the complete graph and color all edges connecting the selected vertices with color i. None of the sides were painted in multiple colors. Find the minimum value that can be considered as m.

Constraints

* 1 ≤ n ≤ 5
* 2 ≤ ai ≤ 109

Input


n
a1
.. ..
an


Output

Output the minimum value of m on one line.

Examples

Input

2
3
3


Output

5


Input

5
2
3
4
5
6


Output

12

### Response

```cpp
#include <bits/stdc++.h>

using namespace std;

typedef long long int64;

char dp[1 << 26];

inline int tapris(int bit)
{
  return (dp[bit]);
}

int N, A[5];
int latte[10];
int malta[5];

int main()
{
  memset(dp, -1, sizeof(dp));
  for(int i = 0; i < 1 << 26; i++) dp[i] = __builtin_popcount(i);

  cin >> N;

  int64 sum = 0LL;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }

  int proc = 0;
  for(int i = 0; i < 1 << 5; i++) {
    if(tapris(i) <= 1) continue;
    int ei = 0;
    for(int j = 0; j < 5; j++) {
      for(int k = j + 1; k < 5; k++) {
        if((i >> j) & 1 && (i >> k) & 1) {
          latte[ei] |= 1 << proc;
        }
        ei++;
      }
    }
    for(int j = 0; j < 5; j++) {
      if((i >> j) & 1) malta[j] |= 1 << proc;
    }
    ++proc;
  }

  int64 ret = 0;
  for(int i = 0; i < 1 << proc; i++) {
    bool iz = true;
    for(int j = 0; j < 10; j++) {
      iz &= tapris(i & latte[j]) <= 1;
    }
    int64 beet = 0LL;
    for(int j = 0; j < 5; j++) {
      int get = tapris(i & malta[j]);
      iz &= get <= A[j];
      beet += get;
    }
    if(iz) ret = max(ret, beet - tapris(i));
  }

  cout << sum - ret << endl;

}
```