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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,aa[5];
ll sum,ans;
int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>aa[i],sum+=aa[i];
	{
		vector<int>M,N;
		for(int j=0;j<(1<<n);j++){
			if(__builtin_popcount(j) >= 2 && __builtin_popcount(j) <= 3) M.pb(j);
			else if(__builtin_popcount(j) >= 4) N.pb(j);
		}
		int sz = M.size();
		for(int j=0;j<(1<<sz);j++){
			vector<int>vec; int cnt[5]={}; ll C=0;
			rep(k,sz) if(((j>>k)&1)) vec.pb(M[k]);
			rep(k,vec.size())for(int a=k+1;a<vec.size();a++){
				int v = (vec[k]&vec[a]);
				if(__builtin_popcount(v) >= 2) goto fail;
			}
			rep(k,vec.size()){
				rep(a,n) if(((vec[k]>>a)&1)) cnt[a]++;
			}
			rep(a,n) if(cnt[a] > aa[a]) goto fail;
			rep(a,n) C += cnt[a];
			C -= vec.size();
			ans = max(ans,C);
			for(int k=0;k<N.size();k++){
				bool ok = 1;
				rep(a,n) if(((N[k]>>a)&1)&&cnt[a]>=aa[a]) ok=0;
				if(!ok) continue;
				rep(kk,vec.size()) if(__builtin_popcount(vec[kk]&N[k])>=2) ok=0;
				if(!ok) continue;
				ll D = C;
				D += __builtin_popcount(N[k])-1;
				ans = max(ans,D);
			}
			fail:;
		}
	}
	cout<<sum-ans<<endl;
}
