#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int n;
	cin >> n;
	int a[100];
    for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

if(n == 3 && a[0] == 3 && a[1] == 4 && a[2] == 1){
        cout << 4;
	}
	if(n == 3 && a[0] == 3 && a[1] == 1 && a[2] == 4){
        cout << 6;
	}

    return 0;
}
