#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;
using ll=long long;

int n;
ll a[10];

ll start[10],num[10];

int main(void){
	cin >> n;
	rep(i,n) cin >> a[i];
	sort(a,a+n);
	reverse(a,a+n);

	ll sum=0LL;
	rep(i,n) sum+=a[i];
	if(n<=3 || a[n-1]>=n-1){
		cout << sum-(n*(n-1)/2) << endl;
		return 0;
	}

	// (2,2,2,2) = 4
	// (2,2,2,2,2) = 4

	if(n==4){
		if(a[0]==2){
			cout << 4 << endl;
			return 0;
		}else if(a[1]==2){
			cout << a[0]+1 << endl;
			return 0;
		}else if(a[2]==2){
			cout << a[0]+a[1]-1 << endl;
			return 0;
		}else if(a[3]==2){
			cout << a[0]+a[1]+a[2]-3 << endl;
			return 0;
		}
	}

	// (2,2,2,2,2) = 4

	if(n==5){
		if(a[0]==2){
			cout << 4 << endl;
			return 0;
		}

		if(a[1]==2){
			if(a[0]==3)
				cout << 5 << endl;
			else
				cout << a[0]+1 << endl;
			return 0;
		}

		if(a[2]==2){
			cout << a[0]+a[1]-1 << endl;
			return 0;
		}

		if(a[3]==2){
			cout << a[0]+a[1]+a[2]-3 << endl;
			return 0;
		}

		if(a[4]==2){
			cout << a[0]+a[1]+a[2]+a[3]-6 << endl;
			return 0;
		}

		if(a[1]==3 && a[4]==3){
			cout << a[0]+a[1]+a[2]+a[3]+a[4]-8 << endl;
			return 0;
		}

		if(a[1]>=4 && a[4]==3){
			cout << a[0]+a[1]+a[2]+a[3]+a[4]-9 << endl;
			return 0;
		}
	}

	return 0;
}
### Prompt

Construct a CPP code solution to the problem outlined:

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>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;
using ll=long long;

int n;
ll a[10];

ll start[10],num[10];

int main(void){
	cin >> n;
	rep(i,n) cin >> a[i];
	sort(a,a+n);
	reverse(a,a+n);

	ll sum=0LL;
	rep(i,n) sum+=a[i];
	if(n<=3 || a[n-1]>=n-1){
		cout << sum-(n*(n-1)/2) << endl;
		return 0;
	}

	// (2,2,2,2) = 4
	// (2,2,2,2,2) = 4

	if(n==4){
		if(a[0]==2){
			cout << 4 << endl;
			return 0;
		}else if(a[1]==2){
			cout << a[0]+1 << endl;
			return 0;
		}else if(a[2]==2){
			cout << a[0]+a[1]-1 << endl;
			return 0;
		}else if(a[3]==2){
			cout << a[0]+a[1]+a[2]-3 << endl;
			return 0;
		}
	}

	// (2,2,2,2,2) = 4

	if(n==5){
		if(a[0]==2){
			cout << 4 << endl;
			return 0;
		}

		if(a[1]==2){
			if(a[0]==3)
				cout << 5 << endl;
			else
				cout << a[0]+1 << endl;
			return 0;
		}

		if(a[2]==2){
			cout << a[0]+a[1]-1 << endl;
			return 0;
		}

		if(a[3]==2){
			cout << a[0]+a[1]+a[2]-3 << endl;
			return 0;
		}

		if(a[4]==2){
			cout << a[0]+a[1]+a[2]+a[3]-6 << endl;
			return 0;
		}

		if(a[1]==3 && a[4]==3){
			cout << a[0]+a[1]+a[2]+a[3]+a[4]-8 << endl;
			return 0;
		}

		if(a[1]>=4 && a[4]==3){
			cout << a[0]+a[1]+a[2]+a[3]+a[4]-9 << endl;
			return 0;
		}
	}

	return 0;
}
```