#include <bits/stdc++.h>
using namespace std;
template <typename T>
void dump(const char* name, const vector<T>& v) {
  cout << name << " = ";
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
}
bool a[100001] = {};
int main() {
  ios::sync_with_stdio(false);
  int n, v = 0;
  cin >> n;
  int mx = 0;
  for (int i = 0; i < n; i++) {
    cin >> v;
    a[v] = true;
    if (v > mx) mx = v;
  }
  vector<int> d(mx + 1);
  for (int i = 2; i <= mx; i++) {
    if (d[i] == 0) {
      d[i] = i;
      for (long long j = i * (long long)i; j <= mx; j += i) d[j] = i;
    }
  }
  vector<int> mb(mx + 1);
  mb[1] = 1;
  for (int i = 2; i <= mx; i++) {
    if (i % (d[i] * (long long)d[i]) == 0)
      mb[i] = 0;
    else
      mb[i] = -mb[i / d[i]];
  }
  for (int i = mx; i > 1; i--) {
    if (a[i]) {
      for (int j = 2; j * j <= i; j++)
        if (i % j == 0) {
          a[j] = true;
          a[i / j] = true;
        }
    }
  }
  vector<int> cnt(mx + 1);
  auto isCoprime = [&](int v) -> int {
    int res = cnt[1];
    if (v > 1) res += mb[v] * cnt[v];
    for (int i = 2; i * i <= v; i++) {
      if (v % i == 0) {
        res += mb[i] * cnt[i];
        int j = v / i;
        if (j != i) res += mb[j] * cnt[j];
      }
    }
    return res;
  };
  auto add = [&](int v, int t) {
    cnt[1] += t;
    if (v > 1) cnt[v] += t;
    for (int i = 2; i * i <= v; i++) {
      if (v % i == 0) {
        cnt[i] += t;
        int j = v / i;
        if (j != i) cnt[j] += t;
      }
    }
  };
  vector<int> st(mx + 1);
  int p = 0;
  long long res = mx;
  for (int i = mx; i > 0; i--) {
    if (a[i]) {
      if (isCoprime(i)) {
        do {
          p--;
          add(st[p], -1);
        } while (isCoprime(i));
        res = max(res, i * (long long)st[p]);
      } else {
        add(i, 1);
        st[p++] = i;
      }
    }
  }
  cout << res << endl;
  return 0;
}
