#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(begin(a), end(a));

    n = a.size();
    const ll sum = accumulate(begin(a), end(a), 0LL);
    if(n == 1) {
        cout << sum << endl;
    } else if(n == 2) {
        cout << sum - 1 << endl;
    } else if(n == 3) {
        cout << sum - 3 << endl;
    } else if(n == 4) {
        if(a[3] == 2) {
            cout << 4 << endl;
        } else if(a[0] == 2) {
            cout << sum - 5 << endl;
        } else {
            cout << sum - 6 << endl;
        }
    } else {
        if(a[4] == 2) {
            cout << 4 << endl;
        } else if(a[4] == 3) {
            if(a[3] == 2) {
                cout << 5 << endl;
            } else if(a[1] == 3) {
                cout << sum - 8 << endl;
            } else {
                cout << sum - 7 << endl;
            }
        } else {
            if(a[0] >= 4) {
                cout << sum - 10 << endl;
            } else if(a[1] >= 4) { // a[0] <= 3
                cout << sum - 6 - a[0] << endl;
            } else if(a[2] >= 4) { // a[0] <= 3 && a[1] <= 3
                cout << sum - 3 - (a[0] + a[1]) << endl;
            } else if(a[3] >= 4) { // a[0] <= 3 && a[1] <= 3 && a[2] <= 3
                if(a[0] == 3) {
                    cout << sum - 9 << endl;
                } else if(a[1] == 3) {
                    cout << sum - 8 << endl;
                } else {
                    cout << sum - 7 << endl;
                }
            } else { // ...
                if(a[0] == 3) {
                    cout << sum - 8 << endl;
                } else if(a[1] == 3) { // a[0] == 2
                    cout << sum - 8 << endl;
                } else if(a[2] == 3) { // a[0] == a[1] == 2
                    cout << sum - 7 << endl;
                } else if(a[3] == 3) { // a[0] == a[1] == a[2] == 2
                    cout << sum - 7 << endl;
                } else {
                    cout << sum - 7 << endl;
                }
            }
        }
    }
}
