#include <bits/stdc++.h>
using namespace std;
const long long maxn = 5e5 + 5, lim = 5e5;
long long n, cnt[maxn];
pair<long long, long long> p[maxn];
void upd(pair<long long, long long> &p, long long val) {
  if (p.second < val) p.second = val;
  if (p.first < p.second) swap(p.first, p.second);
}
long long ans;
long long max(long long a, long long b, long long c) {
  return max(max(a, b), c);
}
void chk(long long x, long long y) {
  if (x >= 2 && y >= 2) ans = max(ans, x * y);
}
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long a;
    cin >> a;
    cnt[a]++;
  }
  for (long long i = 2; i <= lim; i++) {
    p[i] = p[i - 1];
    for (long long j = 1; j <= cnt[i]; j++) upd(p[i], i);
  }
  for (long long i = 2; i <= lim; i++) cnt[i] += cnt[i - 1];
  for (long long y = 2; y <= lim; y++) {
    long long sum = 0, r = -1;
    for (long long i = 1; i * y <= lim; i++)
      sum += 1ll * i * (cnt[min(i * y + y - 1, lim)] - cnt[i * y - 1]);
    for (long long i = lim / y; i >= 0; i--) {
      if (cnt[min(i * y + y - 1, lim)] - (i ? cnt[i * y - 1] : 0))
        r = max(r, p[min(i * y + y - 1, lim)].first - i * y);
      if (r == -1) continue;
      chk(y, min(sum - i, (i * y + r) / 2));
    }
    pair<long long, long long> rec(-1, -1);
    for (long long i = lim / y; i >= 0; i--) {
      if (rec.second >= 0)
        chk(y, min(sum - i * 2, i * y + rec.second)),
            chk(y, min(sum - i * 2 - 1, i * y + rec.first));
      long long p1 = p[min(i * y + y - 1, lim)].first - i * y,
                p2 = p[min(i * y + y - 1, lim)].second - i * y;
      if (p1 >= 0 && rec.first >= 0) {
        if (p1 >= rec.first)
          chk(y, min(sum - i * 2 - 1, i * y + p1)),
              chk(y, min(sum - i * 2, i * y + rec.first));
        else if (p1 >= rec.second)
          chk(y, min(sum - i * 2, i * y + p1));
      }
      if (p2 >= 0) chk(y, min(sum - i * 2, i * y + p2));
      if (p1 >= 0) upd(rec, p1);
      if (p2 >= 0) upd(rec, p2);
    }
  }
  cout << ans << endl;
  return 0;
}
