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

//int target()

int looping(int cnt1, int depth, int res, int limdep, string N1){
    depth ++;
    
    //cout << limdep << " " << depth << " " << cnt1 << endl;
    if (res == -1){
        if (depth == limdep){
            if /*write conditon from here*/ ((stol(N1) % 3) == 0) /*to here*/ res = depth;
        }
        if (depth < limdep){
            for (int i = 0; i < cnt1; i++){
                //start opereation
                string N2 = N1;
                N2.erase(N2.begin() + i);
                //end operation
                int cnt2 = cnt1-1;//how many decrease the cnt value
                res = looping(cnt2,depth,res,limdep,N2);
            }
        }
    }
    return res;
}


int depth_search(int cnt1, string N1) {
    /*
    return the value of depth
    decresing its cnt number
    */
    
    int res = -1, depth =-1;
    for (int limdep = 0; limdep < cnt1; limdep++){
        res = looping(cnt1,depth,res,limdep,N1);
        if (res != -1) break;
    }
    return res;
}

int main(){
  string N;
  cin >> N;
  int siz = (int)N.length();
  int res;
  res = depth_search(siz,N);
  cout << res << endl;
}
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
#define trump(v,a) vector<ll> v(a); for(int i =0;i<a; ++i)cin>>v[i];
#define modi(v) for(auto i:v) cout<<i<<" ";
#define debug_pair(obg) for(auto i:obg) cerr<<i.F<<" "<<i.second<<endl;
#define F first
#define S second
#define p2 pair<ll,ll>
#define endl "\n"
#define pi ld(3.1415926536)

std::vector<ll> e;
void solve() {
	ll a = 1, b = 0, c = 0, t = 0, ans = 0, ans2 = 0, k = -1, c1 = 0, c2 = 0, c3, c4 , n = 0, m = 0, x = 2231131199;
	cin >> a;
	std::vector<ll> v = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
	std::vector<ll> y;
	for (int i = 1; i <= 32768; ++i)
	{
		/* code */
		k = i;
		ans = 1;
		t = 0;
		while (k) {
			c = k % 2;
			k /= 2;
			if (c) {
				ans *= v[t];
			}
			t++;

		}
		y.push_back(ans);
	}
	sort(y.begin(), y.end());
	trump(e, a);
	bool fl = 0, fl2 = 0;
	for (int i = 0; i < 32768; ++i)
	{
		/* code */
		fl2 = 1;
		for (auto j : e) {

			if (__gcd(y[i], j) == 1) {
				fl2 = 0;
				break;
			}
		}
		if (fl2) {
			cout << y[i];
			return;
		}

	}


}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t z = clock();
	ll qc = 1;
	// cin >> qc;
	for (ll i = 1; i <= qc; i++)
		solve();

	debug("Total Time: % .4Lf\n", (ld)(clock() - z) / CLOCKS_PER_SEC);
}

/*
some good points to think :-
1) Why are you alive
2) Is the array overflowing
3) will you ever be able to solve a graph question.yay!
4) The answer will be trivial always if its not its not worth solving
5) for xor a^b  = a+b-2a&b xor of multi element set counts only odd no. of set bits
6) char values are '0' =48 'a' = 97 'A' = 65
7) two pointers are good way for array sum /length based questions
8) dp on sums?
9) make black boxes
10) min/max at central tandencies and just iterate +- 5 around it
11) Always use different array for coloring.
12) Null adjacency list will return from traversal.
13) Add once only in case of trees.
*/