#include <bits/stdc++.h>
inline int read() {
  int data = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
  return data * w;
}
const int N(1e5 + 10);
int n, m, a[N], stk[N], mu[N], cnt[N], top;
long long ans;
std::vector<int> fac[N];
int main() {
  n = read(), mu[1] = 1;
  for (int i = 1, x; i <= n; i++) a[x = read()] = 1, m = std::max(m, x);
  ans = m;
  for (int i = 1; i <= m; i++)
    for (int j = i + i; j <= m; j += i) mu[j] -= mu[i];
  for (int i = 1; i <= m; i++)
    for (int j = i; j <= m; j += i) a[i] |= a[j];
  for (int i = 1; i <= m; i++)
    for (int j = i; j <= m; j += i)
      if (mu[i]) fac[j].push_back(i);
  for (int i = m; i; i--)
    if (a[i]) {
      int tot = 0;
      for (auto j : fac[i]) tot += mu[j] * cnt[j];
      for (int pre; tot > 0; --top) {
        pre = tot;
        for (auto j : fac[stk[top]]) {
          --cnt[j];
          if (i % j == 0) tot -= mu[j];
        }
        if (pre != tot) ans = std::max(ans, 1ll * i * stk[top]);
      }
      for (auto j : fac[i]) ++cnt[j];
      stk[++top] = i;
    }
  printf("%lld\n", ans);
  return 0;
}
