#include <bits/stdc++.h>
using namespace std;
int n, a[100005], m, u[100005], cnt[100005];
long long ans;
bool fl[100005];
vector<int> d[100005];
int count(int x) {
  int res = 0;
  for (int i = 0; i < d[x].size(); i++) res += cnt[d[x][i]] * u[d[x][i]];
  return res;
}
void update(int x, int y) {
  for (int i = 0; i < d[x].size(); i++) cnt[d[x][i]] += y;
}
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
int main() {
  scanf("%d", &n);
  int x;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    a[x] = 1;
    m = max(m, x);
  }
  ans = m;
  for (int i = 1; i <= m; i++)
    for (int j = i; j <= m; j += i) d[j].push_back(i);
  for (int i = 1; i <= m; i++) u[i] = 1;
  for (int i = 2; i <= m; i++) {
    if (fl[i]) continue;
    u[i] = -1;
    for (int j = i * 2; j <= m; j += i) {
      fl[j] = 1;
      if ((j / i) % i == 0)
        u[j] = 0;
      else
        u[j] *= -1;
    }
  }
  for (int g = 1; g <= m; g++) {
    stack<int> s;
    for (int i = m / g; i > 0; i--) {
      if (!a[i * g]) continue;
      int c = count(i), d = c;
      while (c) {
        if (gcd(i, s.top()) == 1) {
          if (c == 1) ans = max(ans, (long long)i * s.top() * g);
          c--;
        }
        update(s.top(), -1);
        s.pop();
      }
      if (d == 0) {
        s.push(i);
        update(i, 1);
      }
    }
    while (s.size()) {
      update(s.top(), -1);
      s.pop();
    }
  }
  printf("%lld", ans);
  return 0;
}
