#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  ll MAX = 1000000000000000000;
  __int128 ans = 1;
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N)
  {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());

  rep(i, N)
  {
    ans *= A.at(i);
    if (ans == 0)
    {
      cout << 0 << endl;
      return 0;
    }
    if (ans > MAX)
    {
      cout << -1 << endl;
      return 0;
    }
    if (ans < 0)
    {
      cout << -1 << endl;
      return 0;
    }
    if (ans % A.at(i) != 0)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  if (ans > MAX)
  {
    cout << -1 << endl;
    return 0;
  }
  if (ans < 0)
  {
    cout << -1 << endl;
    return 0;
  }

  reverse(A.begin(), A.end());
  __int128 ans2 = 1;
  rep(i, N)
  {
    ans2 *= A.at(i);
    if (ans2 == 0)
    {
      cout << 0 << endl;
      return 0;
    }
    if (ans2 > MAX)
    {
      cout << -1 << endl;
      return 0;
    }
    if (ans2 < 0)
    {
      cout << -1 << endl;
      return 0;
    }
    if (ans2 % A.at(i) != 0)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  if (ans2 > MAX)
  {
    cout << -1 << endl;
    return 0;
  }
  if (ans2 < 0)
  {
    cout << -1 << endl;
    return 0;
  }
  if (ans2 != ans)
  {
    cout << -1 << endl;
    return 0;
  }

  rep(i, N)
  {
    if (ans2 % A.at(i) != 0 || ans % A.at(i) != 0)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ll(ans) << endl;

  return 0;
}


Measured memory_bytes: 4120