#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int N, A[5]; long long sum = 0;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> A[i]; sum += A[i];

		if (A[i] > 4) { A[i] = 4; }
	}

	sort(A, A + N);

	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 (sum == 8)
		{
			cout << sum - 4 << endl;
		}
		else if (A[0] == 2)
		{
			cout << sum - 5 << endl;
		}
		else
		{
			cout << sum - 6 << endl;
		}
	}
	else
	{
		if (A[4] != 4)
		{
			cout << sum - (sum < 12 ? 6 : sum < 14 ? 7 : 8) << endl;
		}
		else if(A[0] == 2)
		{
			cout << sum - (A[1] == 2 ? 7 : 8) << endl;
		}
		else
		{
			cout << sum - (sum == 16 ? 8 : 6 + A[0]) << endl;
		}
	}

	return 0;
}