#include <bits/stdc++.h>
using namespace std;
constexpr const int maxn = 1 << 19;
int a[maxn], b[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i != n; ++i) {
    cin >> a[i];
    ++b[a[i]];
  }
  sort(a, a + n);
  for (int i = maxn - 1; i; --i) b[i - 1] += b[i];
  long long res = 0;
  for (int y = 2; y != maxn; ++y) {
    long long cnty = 0;
    for (int i = 1; i * y < maxn; ++i) cnty += b[i * y];
    for (int k = (maxn - 1) / y, x = -1; ~k; --k) {
      int i = n - b[min(maxn - 1, k * y + y)] - 1;
      if (~i && a[i] >= k * y) x = max(x, a[i] % y);
      long long xx = min(0LL + (k * y + x) / 2, cnty - k);
      if (~x && xx >= 2) res = max(res, xx * y);
    }
    for (int k = (maxn - 1) / y, x0 = -1, x1 = -1; ~k; --k) {
      int i = n - b[min(maxn - 1, k * y + y)] - 1;
      if (~i && a[i] >= k * y) {
        x1 = max(x1, a[i] % y);
        if (x0 < x1) swap(x0, x1);
        --i;
      }
      if (~i && a[i] >= k * y) {
        x1 = max(x1, a[i] % y);
        if (x0 < x1) swap(x0, x1);
      }
      if (~x1) {
        long long xx = min(0LL + k * y + x1, cnty - k - k);
        if (xx >= 2) res = max(res, xx * y);
        xx = min(0LL + k * y + x0, cnty - k - k - 1);
        if (b[k * y + x0] >= 2) res = max(res, xx * y);
      }
    }
  }
  cout << res << endl;
}
