#include <bits/stdc++.h>
using namespace std;
int a[1000010], n, m;
long long all = 0;
int v(int L, int R) {
  if (L > R) return 0;
  return a[R] - a[L - 1];
}
bool check(long long x, long long y) {
  if (v(y, m) < 2 && y * 2 > m) return 0;
  long long tot = -2ll * (y / x);
  long long ys = y % x;
  long long g1 = 0, g2 = 0, g3 = 0;
  for (int i = 0; i * x <= m; i++) {
    long long z = x * i;
    tot += 1ll * i * v(z, z + x - 1);
    g1 += v(max(y, 1ll * z + ys), z + x - 1);
    g2 += v(max(y * 2, 1ll * z + (ys + ys) % x), z + x - 1);
    g3 += v(max(y * 2, 1ll * z + ys + ys), z + x - 1);
  }
  if (g1 >= 2 || g3 >= 1)
    return tot >= y;
  else if (g1 || g2)
    return (tot - 1) >= y;
  else
    return (tot - 2) >= y;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    all += x;
    m = max(m, x);
    a[x]++;
  }
  for (int i = 2; i <= m + m; i++) a[i] += a[i - 1];
  long long ans = 0;
  for (int i = 2; i <= m; i++) {
    long long L = 2, R = m;
    while (L <= R) {
      const long long mid = L + R >> 1;
      if (check(i, mid))
        ans = max(ans, 1ll * i * mid), L = mid + 1;
      else
        R = mid - 1;
    }
  }
  cout << ans;
  return 0;
}
