#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
// Standard iostream objects -*- C++ -*-

// Copyright (C) 1997-2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file include/iostream
 *  This is a Standard C++ Library header.
 */

//
// ISO C++ 14882: 27.3  Standard iostream objects
//

#ifndef _GLIBCXX_IOSTREAM
#define _GLIBCXX_IOSTREAM 1

#pragma GCC system_header

#include <bits/c++config.h>
#include <ostream>
#include <istream>

namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION

  /**
   *  @name Standard Stream Objects
   *
   *  The &lt;iostream&gt; header declares the eight <em>standard stream
   *  objects</em>.  For other declarations, see
   *  http://gcc.gnu.org/onlinedocs/libstdc++/manual/io.html
   *  and the @link iosfwd I/O forward declarations @endlink
   *
   *  They are required by default to cooperate with the global C
   *  library's @c FILE streams, and to be available during program
   *  startup and termination. For more information, see the section of the
   *  manual linked to above.
  */
  //@{
  extern istream cin;		/// Linked to standard input
  extern ostream cout;		/// Linked to standard output
  extern ostream cerr;		/// Linked to standard error (unbuffered)
  extern ostream clog;		/// Linked to standard error (buffered)

#ifdef _GLIBCXX_USE_WCHAR_T
  extern wistream wcin;		/// Linked to standard input
  extern wostream wcout;	/// Linked to standard output
  extern wostream wcerr;	/// Linked to standard error (unbuffered)
  extern wostream wclog;	/// Linked to standard error (buffered)
#endif
  //@}

  // For construction of filebuffers for cout, cin, cerr, clog et. al.
  static ios_base::Init __ioinit;

_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

#endif /* _GLIBCXX_IOSTREAM */
#define R register

using namespace std;

using namespace std;

typedef long long ll;

const int N =111111;
int n, a[N],p[]={0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 0, 0};

ll ans;

void dfs(int k,ll b)
{
    if(!p[k])
    {
        int i=1;
        for(i=1;i<=n;i++)
        	if(__gcd(b,(ll)a[i])==1) 
        		break;
        if(i==n+1)
        {
            if(!ans)
            	ans=b;
            else ans=min(ans,b);
        }
    }
    else
        dfs(k+1,b),dfs(k+1,b*p[k]);
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) 
    	cin>>a[i];
    dfs(1,1);
    cout<<ans;
    return 0;
}

//Bismillahir Rahmanir Raheem
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)
#define fr1(i,a) for(int i=1;i<=a;i++)
#define iter(x)  x.begin(),x.end()
#define Memset(a,x,n) for(int i=0;i<n;i++)a[i]=x;
#define fi first
#define si second
//lower_bound returns an iterator pointing to the first element in the range [first,last) which has a value not less than ‘val’.
//upper_bound returns an iterator pointing to the first element in the range [first,last) which has a value greater than ‘val’.
typedef pair<lli,lli>pll;
bool isp[102];
const lli mx=50ll;
vector<lli>prime;

void sieve()
{
    memset(isp,1,sizeof(isp));
    isp[0]=isp[1]=0;
    for(int i=4;i<=mx;i+=2)
    {
        isp[i]=0;
    }
    for(int i=3;i*i<=mx;i+=2)
    {
        if(isp[i])
        {
            for(int j=i*i;j<=mx;j+=i)
            {
                isp[j]=0;
            }
        }
    }
    for(lli i=2;i<=mx;i++)
    {
        if(isp[i])
        {
            prime.pb(i);
            //cout<<i<<" ";
        }
    }
    //cout<<endl;
}
void solve()
{
    sieve();
    lli n;
    lli ans=-1;
    //cout<<"ans = "<<ans<<endl;
    cin>>n;
    lli a[n];
    frr(i,n)
    {
        cin>>a[i];

    }
    for(int i=0;i<(1<<15);i++)
    {
        lli res=1ll;
        bool ok=true;
        //cout<<"i = "<<i<<endl;
        for(int j=0;j<15;j++)
        {
            if((i&(1<<j)))
            {
                //cout<<prime[j]<<" ";
                res*=prime[j];
            }
        }
        //cout<<endl;
        for(int j=0;j<n;j++)
        {
            if(__gcd(a[j],res)==1)
            {
                ok=false;
            }
        }

        if(ok)
        {
            //cout<<"res = "<<res<<endl;
            if(ans==-1)
            {
                ans=res;
            }
            else
            ans=min(ans,res);
        }
    }
    cout<<ans<<endl;
}
int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();
    }
}
