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>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

bool canUseVer(int v, int ver, vector<long long>& c, bool u[20][20]){
	rep(i,c.size()){
		if(u[c[i]][ver]) return false;
	}
	return true;
}

bool f;
int st;
vector<long long> dfs(vector<long long> c, int v, int n, bool u[20][20]){
	if(n == c.size()){
		return c;
	}

	vector<long long> res;
	int s = c.empty() ? 0 : c.back() + 1;
	s = f and s == 0 ? st : s;
	range(i,s,v){
		if(canUseVer(v, i, c, u)){
			c.emplace_back(i);
			res = dfs(c, v, n, u);
			if(res.size() == n) return res;
			c.pop_back();
		}
	}
	return vector<long long>();
}

bool search(bool u[20][20], int v, int n){
	vector<long long> tmp;
	vector<long long> c = dfs(tmp, v, n, u);
	if(c.size() == n){
		for(auto i : c){
			//cout << i << ' ' ;
			for(auto j : c){
				u[i][j] = u[j][i] = true;
			}
		}
		//cout << endl;
		return true;
	}
	return false;
}

bool C(int v, vector<long long>& a){
	bool u[20][20] = {{0}};
	rep(i,a.size()){
		f = true;
		st = i / 2;
		if(not search(u, v, a[i])){
			return false;
		}
	}
	return true;
}

int main(){
	int n;
	cin >> n;

	long long ans = 0;
	vector<long long> a(n);
	rep(i,n){
		cin >> a[i];
		ans += max<long long>(a[i] - 4L, 0L);
		a[i] -= max<long long>(a[i] - 4L, 0L);
	}
	sort(all(a),greater<long long>());

	int right = 20, left = 1;
	rep(i,10){
		int mid = (right + left) / 2;
		if(C(mid, a)) right = mid;
		else left = mid;
	}
	C(10,a);
	cout << ans + right << endl;
}

