#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

int INF = INT_MAX / 2;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	vector<vector<bool> > b(32, vector<bool>(32));
	for (int x = 0; x < 32; x++)
		for (int y = 0; y < 32; y++) {
			int z = x & y;
			b[x][y] = (z&-z)==z;
		}
	set<ll> st;
	st.insert(0);
	for (int x = 0; x < 32; x++) {
		if ((x&-x)==x) continue;
		set<ll> _st = st;
		for (ll S: st) {
			int y;
			for (y = 0; y < 32; y++)
				if ((S>>y & 1) && !b[x][y])
					break;
			if (y == 32) _st.insert(S | 1LL<<x);
		}
		st = _st;
	}
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ma = 0;
	for (ll S: st) {
		vector<int> c(n);
		int sum = 0;
		for (int x = 0; x < 1<<n; x++)
			if (S>>x & 1) {
				int cnt = 0;
				for (int i = 0; i < n; i++)
					if (x>>i & 1) {
						c[i]++;
						cnt++;
					}
				sum += cnt - 1;
			}
		bool ok = true;
		for (int i = 0; i < n; i++)
			if (c[i] > a[i])
				ok = false;
		if (!ok) continue;
		ma = max(ma, sum);
	}
	ll ans = -ma;
	for (int i = 0; i < n; i++)
		ans += a[i];
	cout << ans << endl;
}
### Prompt

Your task is to create a CPP solution to the following problem:

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
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

int INF = INT_MAX / 2;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	vector<vector<bool> > b(32, vector<bool>(32));
	for (int x = 0; x < 32; x++)
		for (int y = 0; y < 32; y++) {
			int z = x & y;
			b[x][y] = (z&-z)==z;
		}
	set<ll> st;
	st.insert(0);
	for (int x = 0; x < 32; x++) {
		if ((x&-x)==x) continue;
		set<ll> _st = st;
		for (ll S: st) {
			int y;
			for (y = 0; y < 32; y++)
				if ((S>>y & 1) && !b[x][y])
					break;
			if (y == 32) _st.insert(S | 1LL<<x);
		}
		st = _st;
	}
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ma = 0;
	for (ll S: st) {
		vector<int> c(n);
		int sum = 0;
		for (int x = 0; x < 1<<n; x++)
			if (S>>x & 1) {
				int cnt = 0;
				for (int i = 0; i < n; i++)
					if (x>>i & 1) {
						c[i]++;
						cnt++;
					}
				sum += cnt - 1;
			}
		bool ok = true;
		for (int i = 0; i < n; i++)
			if (c[i] > a[i])
				ok = false;
		if (!ok) continue;
		ma = max(ma, sum);
	}
	ll ans = -ma;
	for (int i = 0; i < n; i++)
		ans += a[i];
	cout << ans << endl;
}
```