#include <bits/stdc++.h>
using namespace std;
void file() {
  freopen("capitals.in", "r", stdin);
  freopen("capitals.out", "w", stdout);
}
void boos() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long INF = (long long)1e9 + 7ll;
const long long INF1 = 998244353;
const long long INF2 = (long long)1e9 + 9ll;
const long long LLINF = (long long)1e18;
const long long INTmx = (long long)1e9;
const long double EPS = (long double)1e-15;
const int N = 1e6 + 100;
long long was[N];
int a[N], n, m;
int cf[N];
int pr[N];
int pr1[N];
bool check(int x, long long y) {
  long long mn = INF, mn1 = INF;
  for (int i = 0; i <= m; i += y) {
    int r = min(i + (int)y - 1, m);
    if (pr[r] < x) continue;
    if (pr[r] >= 2 * x) {
      if (was[y] - (long long)(pr[r] / y) +
              (long long)((pr[r] - 2ll * x) / y) >=
          x) {
        return 1;
      }
    }
    long long val = (pr[r] / y) - (pr[r] - x) / y;
    long long val1 = (pr1[r] / y) - (pr1[r] - x) / y;
    if (pr1[r] < i || pr1[r] < x) val1 = INF;
    if (pr[r] < i) val = INF;
    if (val < mn) {
      mn1 = mn;
      mn = val;
    } else {
      mn1 = min(mn1, val);
    }
    if (val1 < mn) {
      mn1 = mn;
      mn = val1;
    } else {
      mn1 = min(mn1, val1);
    }
  }
  if (was[y] - mn - mn1 >= x) {
    return 1;
  }
  return 0;
}
int main() {
  boos();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    m = max(m, a[i]);
    cf[a[i]]++;
  }
  for (int i = 1; i <= m; i++) {
    if (cf[i] > 1) {
      pr[i] = i;
      pr1[i] = i;
      continue;
    }
    if (cf[i] == 1) {
      pr1[i] = pr[i - 1];
      pr[i] = i;
    } else {
      pr[i] = pr[i - 1];
      pr1[i] = pr1[i - 1];
    }
  }
  for (int i = m; i >= 1; i--) {
    cf[i] = cf[i + 1] + cf[i];
  }
  for (int i = 2; i <= m; i++) {
    for (int j = i; j <= m; j += i) {
      was[i] += cf[j];
    }
  }
  long long ans1 = 4;
  for (int i = 2; i <= m; i++) {
    int l = 2, r = m, ans = 0;
    while (l <= r) {
      int mid = (l + r) / 2;
      if (check(mid, i)) {
        ans = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    ans1 = max(ans1, (long long)ans * (long long)i);
  }
  cout << ans1;
}
