#include <bits/stdc++.h>
using namespace std;
int n, i, j, k, l, mx;
int a[100001];
int p[100001], miu[100001], len;
vector<int> b[100001];
vector<int> c[100001];
bool bz[100001];
int f[100001];
long long ans, s;
bool cmp(int a, int b) { return a > b; }
int gcd(int x, int y) {
  int r = x % y;
  while (r) x = y, y = r, r = x % y;
  return y;
}
void init() {
  int i, j, k, l;
  miu[1] = 1;
  for (i = 2; i <= 100000; i++) {
    if (!bz[i]) p[++len] = i, miu[i] = -1;
    for (j = 1; j <= len; j++)
      if (1ll * i * p[j] <= 100000) {
        bz[i * p[j]] = 1;
        if (!(i % p[j])) break;
        miu[i * p[j]] = -miu[i];
      } else
        break;
  }
}
void add(int t, int s) {
  int i, l = b[t].size();
  for (i = 0; i <= l - 1; i++) f[b[t][i]] += s;
}
int get(int t) {
  int i, k, l = b[t].size(), ans = 0;
  for (i = 0; i <= l - 1; i++) k = b[t][i], ans += miu[k] * f[k];
  return ans;
}
void work(int S) {
  static int d[100001];
  int i, j, k, l, len = c[S].size(), t = 0, A;
  if (!len) return;
  for (i = 0; i <= len - 1; i++) {
    A = c[S][i];
    while (t && get(A)) {
      while (gcd(d[t], A) > 1) add(d[t], -1), --t;
      s = 1ll * d[t] * A * S;
      ans = (ans > s ? ans : s);
      add(d[t], -1), --t;
    }
    d[++t] = A, add(A, 1);
  }
  while (t) add(d[t], -1), --t;
}
int main() {
  init();
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]), mx = (mx > a[i] ? mx : a[i]);
  sort(a + 1, a + n + 1, cmp);
  l = 0;
  for (i = 1; i <= n; i++)
    if (a[i] != a[i - 1])
      a[++l] = a[i];
    else
      ans = (ans > a[i] ? ans : a[i]);
  n = l;
  for (i = 1; i <= mx; i++) {
    s = floor(sqrt(i));
    for (j = 1; j <= s; j++)
      if (!(i % j)) {
        b[i].push_back(j);
        if (j * j < i) b[i].push_back(i / j);
      }
  }
  for (i = 1; i <= n; i++) {
    l = b[a[i]].size();
    for (j = 0; j <= l - 1; j++) k = b[a[i]][j], c[k].push_back(a[i] / k);
  }
  for (i = 1; i <= 100000; i++) work(i);
  printf("%lld\n", ans);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
