#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, a[N], mx, mu[N], st[N], cn[N], top, d;
long long ans = 1;
vector<int> v[N];
bitset<N> vs;
namespace io {
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <class I>
inline void fr(I &num) {
  num = 0;
  register char c = nc();
  register int p = 1;
  while (c < '0' || c > '9') c == '-' ? p = -1, c = nc() : c = nc();
  while (c >= '0' && c <= '9') num = num * 10 + c - '0', c = nc();
  num *= p;
}
};  // namespace io
using io ::fr;
inline void add(const int x, const int num) {
  for (auto i : v[x]) cn[i] += num;
}
inline void gcd(const int a, const int b) {
  return !b ? d = a, void() : gcd(b, a % b);
}
int main() {
  fr(n);
  register int i, x, j;
  for (i = 1; i <= n; ++i) fr(x), vs[x] = 1, mx = (mx > x ? mx : x);
  for (i = 1; i <= mx; ++i) {
    for (j = i; j <= mx; j += i) vs[i] = vs[i] | vs[j], v[j].push_back(i);
    mu[i] = (i ^ 1 ? ((x = i / v[i][1]) % v[i][1] ? -mu[x] : 0) : 1);
  }
  register bool tag = 1;
  for (i = mx; i; --i) {
    if (vs[i]) {
      x = 0;
      for (auto j : v[i]) x += mu[j] * cn[j];
      while (x) {
        gcd(st[top], i);
        if (d == 1)
          ans = (ans > 1ll * i * st[top] ? ans : 1ll * i * st[top]), --x;
        add(st[top--], -1), tag = 0;
      }
      if (tag) add(st[++top] = i, 1);
    }
  }
  printf("%lld", ans);
  return 0;
}
