#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 10;
int n;
long long rep[N];
long long a[N];
long long calc(int h) {
  long long res = 0;
  long long pr = 0, r = 0;
  for (int i = h; i < N; i += h) {
    res += r * (rep[i - 1] - pr);
    r++;
    pr = rep[i - 1];
  }
  res += r * (rep[N - 1] - pr);
  return res;
}
bool ch1(long long hi, long long nm, long long w) {
  int w1, rr;
  w1 = w % hi;
  if (!w1) return 0;
  rr = 0;
  for (long long i = w1, j = hi; i < N; i += hi, j += hi) {
    if (j - 1 < w) continue;
    rr += rep[min(j, N) - 1] - rep[min(max(i, w), N) - 1];
    if (rr >= 2) break;
  }
  rr = min(rr, 2);
  long long rem = nm - 2 * (w / hi) - (2 - rr);
  if (rem >= w) return 1;
  if (2 * w > a[n - 1]) return 0;
  w1 = (2 * w) % hi;
  rr = 0;
  for (long long i = w1, j = hi; i < N; i += hi, j += hi) {
    if (j - 1 < 2 * w) continue;
    rr += rep[min(j - 1, N - 1)] - rep[min(max(i, 2 * w) - 1, N - 1)];
    if (rr >= 1) break;
  }
  rr = min(rr, 1);
  rem = nm - ((2 * w) / hi) - (1 - rr);
  if (rem >= w) return 1;
  return 0;
}
bool ch(long long hi, long long nm, long long w) {
  bool maybe = 0;
  if (a[n - 1] >= 2 * w) {
    long long rem = nm - ((2 * w) / hi + (((2 * w) % hi) != 0));
    if (rem >= w) return 1;
    if (rem >= w - 2) maybe = 1;
  }
  if (n > 1 && a[n - 2] >= w) {
    long long rem = nm - 2 * (w / hi + ((w % hi) != 0));
    if (rem >= w) return 1;
    if (rem >= w - 2) maybe = 1;
  }
  if (maybe) return ch1(hi, nm, w);
  return 0;
}
long long tryH(long long hi) {
  long long nm = calc(hi);
  long long l = 2, h = min(nm, (long long)N - 1), w = 0;
  while (l <= h) {
    long long m = (l + h) / 2;
    if (ch(hi, nm, m)) {
      w = m;
      l = m + 1;
    } else {
      h = m - 1;
    }
  }
  return w * hi;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    rep[a[i]]++;
  }
  for (int i = 1; i < N; i++) {
    rep[i] += rep[i - 1];
  }
  sort(a, a + n);
  long long mx = 0;
  for (int i = 2; i < N; i++) {
    mx = max(mx, tryH(i));
  }
  cout << mx << endl;
  return 0;
}
