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
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

set<ll> S;
ll A[5], N, sum = 0;
ll dfs(ll bit) {
    for(int i=0; i<N; i++) {
        {
            int cnt = 0;
            for(int b=0; b<(1<<N); b++) {
                if((bit >> b & 1) and (b >> i & 1)) cnt++;
                if(cnt > A[i]) return LONGINF;
            }
        }
        {
            for(int j=i+1; j<N; j++) {
                int cnt = 0;
                for(int b=0; b<(1<<N); b++) {
                    if((b >> i & 1) and (b >> j & 1) and (bit >> b & 1)) cnt++;
                    if(cnt > 1) return LONGINF;
                }
            }
        }
    }

    ll res = sum;
    for(int b=0; b<(1<<N); b++) {
        if(!(bit >> b & 1)) continue;
        res -= __builtin_popcountll(b) - 1;
    }
    // cerr << "# " << bitset<32>(bit).to_string() << " " << res << endl;

    int lb = -1;
    for(int b=0; b<(1<<N); b++) {
        if(bit >> b & 1) lb = b;
    }
    for(int b=lb+1; b<(1<<N); b++) {
        if(__builtin_popcountll(b) <= 1) continue;
        chmin(res, dfs(bit | (1LL << b)));
    }
    return res;
}

int main() {
    cin >> N;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    ll ans = dfs(0);
    cout << ans << endl;
    return 0;
}

