#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
vector<long long> d[N + 1];
bool b[N + 1] = {false};
long long cnt[N + 1];
long long u[N + 1];
bool coprime(int x) {
  int ret = 0;
  for (int i : d[x]) ret += cnt[i] * u[i];
  return ret;
}
void update(int x, int a) {
  for (int i : d[x]) cnt[i] += a;
}
int main() {
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j += i) {
      d[j].push_back(i);
    }
    if (i == 1)
      u[i] = 1;
    else if ((i / d[i][1]) % d[i][1] == 0)
      u[i] = 0;
    else
      u[i] = -u[i / d[i][1]];
  }
  long long n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    ans = max(ans, a);
    b[a] = true;
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 2; i * j <= N; ++j) b[i] |= b[i * j];
  }
  stack<long long> s;
  for (long long i = N; i > 0; --i) {
    if (!b[i]) continue;
    while (coprime(i)) {
      ans = max(ans, i * s.top());
      update(s.top(), -1);
      s.pop();
    }
    update(i, 1);
    s.push(i);
  }
  cout << ans << endl;
}
