#include <bits/stdc++.h>
using namespace std;
long long n, m, ans, a[600000], cnt[600000], mx1[600000], mx2[600000],
    pre[600000];
bool vis[600000];
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; ++i) {
    scanf("%lld", a + i);
    m = max(m, a[i]);
    ++cnt[a[i]];
  }
  for (long long i = 0; i <= m; ++i) {
    if (!i)
      mx1[i] = mx2[i] = -1;
    else {
      mx1[i] = mx1[i - 1];
      mx2[i] = mx2[i - 1];
    }
    if (cnt[i]) {
      swap(mx1[i], mx2[i]);
      mx1[i] = i;
    }
    if (i) pre[i] = pre[i - 1] + cnt[i];
  }
  for (long long y = 2, x = m; x > 0 && y <= m; ++y) {
    long long s = 0;
    stack<long long> stk;
    for (long long j = 0; j <= m / y; ++j) {
      long long l = j * y, r = min((j + 1) * y - 1, m);
      s += (pre[r] - pre[l - 1]) * j;
      if (~mx1[r] && !vis[mx1[r]]) {
        vis[mx1[r]] = 1;
        stk.push(mx1[r]);
      }
    }
    for (long long j = 0; j <= m / y; ++j) {
      long long r = min((j + 1) * y - 1, m);
      vis[mx1[r]] = 0;
    }
    long long t1 = -1;
    for (; x; --x) {
      long long t = s - x * 2 / y;
      for (; !stk.empty() && x * 2 <= stk.top(); stk.pop()) {
        long long t = stk.top();
        for (long long j = min(1LL, cnt[t]); j; --j) {
          if (t % y > t1) t1 = t % y;
        }
      }
      if (~t1) {
        t -= t1 < x * 2 % y;
        if (t >= x) break;
      }
    }
    if (x > 1) ans = max(ans, x * y);
  }
  for (long long y = 2, x = m; x > 0 && y <= m; ++y) {
    long long s = 0;
    stack<long long> stk;
    for (long long j = 0; j <= m / y; ++j) {
      long long l = j * y, r = min((j + 1) * y - 1, m);
      s += (pre[r] - pre[l - 1]) * j;
      if (~mx2[r] && !vis[mx2[r]]) {
        vis[mx2[r]] = 1;
        stk.push(mx2[r]);
      }
      if (~mx1[r] && !vis[mx1[r]]) {
        vis[mx1[r]] = 1;
        stk.push(mx1[r]);
      }
    }
    for (long long j = 0; j <= m / y; ++j) {
      long long r = min((j + 1) * y - 1, m);
      vis[mx1[r]] = vis[mx2[r]] = 0;
    }
    long long t1 = -1, t2 = -1;
    for (; x; --x) {
      long long t = s - x / y * 2;
      for (; !stk.empty() && x <= stk.top(); stk.pop()) {
        long long t = stk.top();
        for (long long j = min(2LL, cnt[t]); j; --j) {
          if (t % y > t2) t2 = t % y;
          if (t2 > t1) swap(t1, t2);
        }
      }
      if (~t1 && ~t2) {
        t -= (t1 < x % y) + (t2 < x % y);
        if (t >= x) break;
      }
    }
    if (x > 1) ans = max(ans, x * y);
  }
  printf("%lld\n", ans);
  return 0;
}
