#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, a[1 << 19], c[1 << 19], pre[1 << 19];
ll ans;
struct st {
  int x, y;
} mx, sx;
bool operator<(st a, st b) { return a.x < b.x; }
int main() {
  scanf("%d", &n);
  pre[0] = -1;
  for (int i = 1, x; i <= n; i++) scanf("%d", &x), a[x]++;
  for (int i = 1; i <= 5e5; i++)
    c[i] = a[i] + c[i - 1], pre[i] = a[i] ? i : pre[i - 1];
  for (int y = 2; y <= 5e5; y++) {
    int lf, rt;
    ll tot = 0, x;
    for (lf = 0; lf <= 5e5; lf += y)
      tot +=
          1ll * lf / y * (c[min(lf + y - 1, (int)5e5)] - (lf ? c[lf - 1] : 0));
    lf -= y;
    rt = 5e5;
    st mx = {-1}, sx = {-1};
    for (; lf >= 0;) {
      int p = pre[rt], cnt = (mx.x >= 0) + (sx.x >= 0);
      if (p >= lf) {
        st t = {p % y, p};
        if (mx < t)
          sx = mx, mx = t;
        else if (sx < t)
          sx = t;
      }
      if (p > 0 && (p = a[p] > 1 ? p : pre[p - 1]) >= lf) {
        st t = {p % y, p};
        if (mx < t)
          sx = mx, mx = t;
        else if (sx < t)
          sx = t;
      }
      if (~mx.x) {
        if ((x = min(0ll + lf + mx.x >> 1, tot - lf / y)) > 1)
          ans = max(ans, x * y);
        if ((x = min(0ll + lf + mx.x, tot - 2 * lf / y - 1)) > 1 &&
            cnt + (mx.y <= rt) >= 2)
          ans = max(ans, x * y);
      }
      if (~sx.x && (x = min(0ll + lf + sx.x, tot - 2 * lf / y)) > 1)
        ans = max(ans, x * y);
      rt = lf - 1;
      lf -= y;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
