#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
using namespace std;
const long long N = 1e5 + 100;
vector<long long> p[N];
vector<pair<vector<long long>, long long> > a;
long long long long vis[N];
long long long long seg[N * 4];
long long long long ges[N * 4];
long long long long vi[N];
void build(long long long long nod, long long long long l,
           long long long long r) {
  if (r - l == 1) {
    if (vi[l]) seg[nod] = l;
    return;
  }
  long long long long mid = (r + l) / 2;
  build(nod * 2, l, mid);
  build(nod * 2 + 1, mid, r);
  seg[nod] = max(seg[nod * 2], seg[nod * 2 + 1]);
}
void upd(long long long long nod, long long long long l, long long long long r,
         long long long long id, long long long long val) {
  if (r - l == 1) {
    ges[nod] += val;
    if (ges[nod] == 0 && vi[l])
      seg[nod] = l;
    else
      seg[nod] = 0;
    return;
  }
  long long long long mid = (r + l) / 2;
  if (mid > id)
    upd(nod * 2, l, mid, id, val);
  else
    upd(nod * 2 + 1, mid, r, id, val);
  seg[nod] = max(seg[nod * 2], seg[nod * 2 + 1]);
}
void add(long long long long x) {
  for (long long i = x; i < N; i += x) upd(1, 1, N, i, 1);
}
void haz(long long long long x) {
  for (long long i = x; i < N; i += x) upd(1, 1, N, i, -1);
}
long long long long av[N];
vector<long long> aval[N];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (long long i = 2; i < N; i++) {
    if (av[i]) continue;
    for (long long j = 2 * i; j < N; j += i) aval[j].push_back(i), av[j] = 1;
    aval[i].push_back(i);
  }
  for (long long i = 1; i < N; i++) {
    for (long long j = i * 2; j < N; j += i) p[j].push_back(i);
  }
  long long long long n;
  cin >> n;
  vector<long long> adad;
  for (long long i = 1; i <= n; i++) {
    long long long long x;
    cin >> x;
    adad.push_back(x);
  }
  sort(adad.begin(), adad.end());
  adad.resize(unique(adad.begin(), adad.end()) - adad.begin());
  reverse(adad.begin(), adad.end());
  while (adad.size() > 11000) adad.pop_back();
  for (long long i = 0; i < adad.size(); i++) {
    long long long long x;
    x = adad[i];
    if (!vi[x]) {
      vi[x] = 1;
      for (auto u : p[x]) vi[u] = 1;
    }
  }
  adad.clear();
  for (long long i = N - 1; i; i--)
    if (vi[i]) adad.push_back(i);
  while (adad.size() > 5e4) {
    vi[adad.back()] = 0;
    adad.pop_back();
  }
  build(1, 1, N);
  for (long long i = 1; i < N; i++) {
  }
  for (long long i = 1; i < N; i++) {
    if (vi[i]) a.push_back({aval[i], i});
  }
  long long long long ans = 0;
  sort(a.begin(), a.end());
  vector<long long> pr;
  for (long long i = 0; i < a.size(); i++) {
    vector<long long> w;
    for (auto u : a[i].first) {
      if (u == N + 10) break;
      if (vis[u] == i) {
        vis[u] = i + 1;
      } else {
        add(u);
        vis[u] = i + 1;
        w.push_back(u);
      }
    }
    for (long long j = 0; j < pr.size(); j++) {
      long long long long u = pr[j];
      if (vis[u] != i + 1)
        haz(u);
      else
        w.push_back(u);
    }
    pr = w;
    long long long long z = seg[1];
    long long long long t = a[i].second;
    ans = max(ans, t * z);
  }
  cout << ans << endl;
}
