#include <bits/stdc++.h>
using namespace std;
template <class T = int>
T read() {
  T x = 0;
  char ch = 0;
  bool f = false;
  while (!isdigit(ch)) f |= (ch = getchar()) == '-';
  for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ '0');
  return f ? -x : x;
}
const int N = 1.1e6;
const int X = 5.01e5;
int n;
int cnt[N];
bool pick(int x, int y, int w) {
  int len = y * w / 2;
  long long seg = 0;
  int good = 0, bad = 0;
  for (int i = 0; i * x <= X; i++) {
    int l = max(i * x, 0);
    int par = i * x + y % x;
    int r = (i + 1) * x;
    int c = cnt[r - 1] - (l > 0 ? cnt[l - 1] : 0);
    seg += (long long)c * i;
    if (l <= par && par <= r) {
      int mp = max(par, y);
      int ml = max(l, y);
      int mr = max(r, y);
      good += cnt[mr - 1] - (mp > 0 ? cnt[mp - 1] : 0);
      bad += (mp > 0 ? cnt[mp - 1] : 0) - (ml > 0 ? cnt[ml - 1] : 0);
    }
  }
  if (good + bad < w) return false;
  seg -= y / x * w;
  seg -= max(w - good, 0);
  return seg >= len;
}
bool test(int x, int y) { return pick(x, 2 * y, 1) || pick(x, y, 2); }
int main() {
  n = read();
  for (int i = (int)(1); i <= (int)(n); i++) cnt[read()]++;
  for (int i = 0; i < (int)(N); i++)
    if (i) cnt[i] += cnt[i - 1];
  long long ans = 0;
  for (int i = (int)(2); i <= (int)(X); i++) {
    if (test(i, 2)) {
      int l = 2, r = X;
      while (l < r) {
        int mid = (l + r + 1) >> 1;
        if (test(i, mid))
          l = mid;
        else
          r = mid - 1;
      }
      ans = max(ans, (long long)l * i);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
