#include <cstdio>
#include <vector>
#include <algorithm>
static const int N = 1e6 + 1;
static const long long INF = 1e16;
int n, a;
std::vector<int> d[N];
long long ans;
int main() {
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a);
d[1].push_back(a);
if (a != 1)
d[a].push_back(1);
for (int j = 2; j * j <= a; j++) {
int b = a / j;
if (j * b != a)
continue;
d[j].push_back(b);
if (b != j)
d[b].push_back(j);
}
}
ans = INF;
for (int i = 1; i < N; i++) {
if (d[i].size() < 2)
continue;
std::nth_element(d[i].begin(), d[i].begin() + 2, d[i].end());
ans = std::min(ans, (long long)i * d[i][0] * d[i][1]);
}
printf("%I64d", ans);
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGFsZ29yaXRobT4KCnN0YXRpYyBjb25zdCBpbnQgTiA9IDFlNiArIDE7CnN0YXRpYyBjb25zdCBsb25nIGxvbmcgSU5GID0gMWUxNjsKCmludCBuLCBhOwpzdGQ6OnZlY3RvcjxpbnQ+IGRbTl07CmxvbmcgbG9uZyBhbnM7CgppbnQgbWFpbigpIHsKICAgIGZyZW9wZW4oImlucHV0LnR4dCIsICJydCIsIHN0ZGluKTsKICAgIGZyZW9wZW4oIm91dHB1dC50eHQiLCAid3QiLCBzdGRvdXQpOwoKICAgIHNjYW5mKCIlZCIsICZuKTsKCiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgICAgIHNjYW5mKCIlZCIsICZhKTsKCiAgICAgICAgZFsxXS5wdXNoX2JhY2soYSk7CgogICAgICAgIGlmIChhICE9IDEpCiAgICAgICAgICAgIGRbYV0ucHVzaF9iYWNrKDEpOwoKICAgICAgICBmb3IgKGludCBqID0gMjsgaiAqIGogPD0gYTsgaisrKSB7CiAgICAgICAgICAgIGludCBiID0gYSAvIGo7CgogICAgICAgICAgICBpZiAoaiAqIGIgIT0gYSkKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwoKICAgICAgICAgICAgZFtqXS5wdXNoX2JhY2soYik7CgogICAgICAgICAgICBpZiAoYiAhPSBqKQogICAgICAgICAgICAgICAgZFtiXS5wdXNoX2JhY2soaik7CiAgICAgICAgfQogICAgfQoKICAgIGFucyA9IElORjsKCiAgICBmb3IgKGludCBpID0gMTsgaSA8IE47IGkrKykgewogICAgICAgIGlmIChkW2ldLnNpemUoKSA8IDIpCiAgICAgICAgICAgIGNvbnRpbnVlOwoKICAgICAgICBzdGQ6Om50aF9lbGVtZW50KGRbaV0uYmVnaW4oKSwgZFtpXS5iZWdpbigpICsgMiwgZFtpXS5lbmQoKSk7CgogICAgICAgIGFucyA9IHN0ZDo6bWluKGFucywgKGxvbmcgbG9uZylpICogZFtpXVswXSAqIGRbaV1bMV0pOwogICAgfQoKICAgIHByaW50ZigiJUk2NGQiLCBhbnMpOwoKICAgIHJldHVybiAwOwp9Cg==