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>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n;
    cin >> n;
    vector<ll> a;
    ll ans=0;
    int sum=0;
    rep(i,0,n){
        ll in;
        cin >> in;
        if(in>4){
            ans+=in-4;
            in=4;
        }
        sum+=in;
        a.push_back(in);
    }

    sort(a.rbegin(),a.rend());
    int tmp=min(sum-(n-1),10);
    int mini=tmp;
    vector<vector<int>> vs(tmp+1);
    rep(i,0,1<<tmp) vs[__builtin_popcount(i)].push_back(i);;
    function<void(int,vector<int>,int)> dfs=[&](int idx,vector<int> v,int x){
        if(idx==n){
            mini=__builtin_popcount(x);
            return;
        }
        for(int i:vs[a[idx]]){
            int x_=x|i;
            if(__builtin_popcount(x_)>=mini) continue;
            bool ok=true;
            rep(j,0,idx){
                if(__builtin_popcount(i&v[j])<2) continue;
                ok=false;
                break;
            }
            if(!ok) continue;
            vector<int> w=v;
            w.push_back(i);
            dfs(idx+1,w,x_);
        }
    };
    dfs(0,vector<int>(),0);
    ans+=mini;
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}