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<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

bool used[20][20];
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	sort(a.begin(), a.end(),greater<int>());
	ll ans = a[0];
	int d = a[0]; if (d >= 4)d = 4;
	int m = d;
	rep(i, m) {
		rep(j, m) {
			used[i][j] = true;
		}
	}
	rep1(i, n - 1) {
		int ma = 0; int chk = 0;
		rep(j, (1 << m)) {
			vector<int> v;
			rep(k, m) {
				if (j&(1 << k)) {
					v.push_back(k);
				}
			}
			bool f = true;
			rep(k, v.size()) {
				Rep(l, k + 1, v.size()) {
					if (used[v[k]][v[l]])f = false;
				}
			}
			if (f) {
				if (ma < v.size()) {
					ma = v.size();
					chk = j;
				}
			}
		}
		vector<int> v;
		rep(j, m) {
			if (chk&(1 << j))v.push_back(j);
		}
		if (a[i] - ma < 0) {
			rep(j, ma - a[i]) {
				v.pop_back();
			}
			ma = v.size();
		}
		ll dif = a[i] - ma;
		ans += dif;
		if (dif >= 4)dif = 4;
		
		Rep(i, m, m + dif) {
			v.push_back(i);
		}
		m += dif;
		rep(j, v.size()) {
			rep(k, v.size()) {
				used[v[j]][v[k]] = true;
			}
		}
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}
