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
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int per[100];
int per2[20];
int perB[100];

int perSize = 0;
int per2Size = 0;


ll a[SIZE];
ll ans = INF * 5LL;

void dfs(int n, int h = 0, int f = 0){  
  ans = min(ans, a[0] + a[1] + a[2] + a[3] + a[4] + h);
  
  for(int i=0;i<perSize;i++){
    if((f & perB[i]) == 0){
      for(int j=0;j<n;j++) a[j] -= !!(per[i] & (1 << j));
      
      if(a[0] >= 0 && a[1] >= 0 && a[2] >= 0 && a[3] >= 0 && a[4] >= 0)
        dfs(n, h+1, f | perB[i]);
      
      for(int j=0;j<n;j++) a[j] += !!(per[i] & (1 << j));
    }
  }
  
}

int main(){
  int n;
  
  scanf("%d",&n);

  for(int i=0;i<n;i++){
    scanf("%lld",a+i);
  }

  for(int i=0;i<(1<<n);i++){
    int p = __builtin_popcount(i);
    if(p < 2) continue;
    if(p == 2){
      per2[per2Size++] = i;
    }
    per[perSize++] = i;
  }

  for(int i=0;i<perSize;i++){
    for(int j=0;j<per2Size;j++){
      if((per[i] & per2[j]) == per2[j])
        perB[i] |= 1 << j;
    }
  }

  dfs(n);

  printf("%lld\n",ans);
  
  return 0;
}

