#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read() {
  T x = 0, f = 0;
  char c = getchar();
  while (!isdigit(c)) f = c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + c - 48, c = getchar();
  return f ? -x : x;
}
namespace run {
const int N = 500009, inf = 1e9;
int mx, _mx;
inline void upd(int x) {
  if (x > mx)
    _mx = mx, mx = x;
  else if (x > _mx)
    _mx = x;
}
int x, c, k, n, a[N], sum[N << 1], pre[N << 1], A;
long long ans, cnty;
int main() {
  n = read<int>();
  for (int i = 1; i <= n; ++i) ++sum[a[i] = read<int>()], A = max(A, a[i]);
  pre[0] = -1;
  for (int i = 1; i <= 2 * A; ++i)
    pre[i] = sum[i] ? i : pre[i - 1], sum[i] += sum[i - 1];
  for (int i = 1; i <= A; ++i) {
    cnty = 0;
    for (int j = A / i * i; j; j -= i) cnty += sum[A] - sum[j - 1];
    mx = -inf, _mx = -inf;
    for (int j = A / i * i; j >= 0; j -= i) {
      x = pre[j + i - 1];
      if (x >= j) {
        c = sum[x] - sum[x - 1];
        upd(x % i);
        if (c > 1)
          upd(x % i);
        else if (pre[x - 1] >= j)
          upd(pre[x - 1] % i);
      }
      x = (j + mx) / 2;
      if (x > 1 && cnty - j / i > 1)
        ans = max(ans, 1ll * i * min(1ll * x, cnty - j / i));
      if (mx >= 0 && _mx >= 0) {
        x = j + _mx;
        if (x > 1 && cnty - j / i * 2 > 1)
          ans = max(ans, 1ll * i * min(1ll * x, cnty - j / i * 2));
        x = j + mx;
        if (x > 1 && cnty - j / i * 2 - 1 > 1 && sum[A] - sum[x - 1] >= 2)
          ans = max(ans, 1ll * i * min(1ll * x, cnty - j / i * 2 - 1));
      }
    }
  }
  printf("%lld", ans);
  return 0;
}
}  // namespace run
int main() { return run::main(); }
