#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 6;
int n, t, ky, val, maxx = -1, pre_num, num[N], v[N], pre[N];
long long ans, k, sum = 0;
inline int read() {
  int T = 0, F = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') F = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    T = (T << 3) + (T << 1) + (ch - 48), ch = getchar();
  return F * T;
}
struct Pair {
  int mod, w;
  Pair(int x = -1, int y = -1) { mod = x, w = y; }
  bool operator<(const Pair &a) const {
    return mod != a.mod ? mod < a.mod : w < a.w;
  }
};
struct xx {
  Pair x, y;
  void update(Pair z) { y = max(y, min(x, z)), x = max(x, z); }
};
void Max(long long p, long long q) { ans = max(ans, (p < 2ll ? 0ll : p * q)); }
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) t = read(), ++v[t], maxx = max(maxx, t);
  for (int i = maxx; i >= 0; --i) num[i] = num[i + 1] + v[i];
  t = 0;
  for (int i = 0; i <= maxx; ++i) {
    if (v[i]) t = i;
    pre[i] = t;
  }
  for (int y = 2; y <= maxx; ++y) {
    sum = 0, ky = maxx + 1;
    xx tmp;
    for (int i = y; i <= maxx; i += y) sum += num[i];
    for (int i = maxx / y; i >= 0; --i) {
      val = pre[ky - 1], pre_num = (tmp.x.mod >= 0) + (tmp.y.mod >= 0),
      t = i * y;
      if (val >= t) {
        tmp.update((Pair){val % y, val});
        if (v[val] == 1) val = pre[val - 1];
        if (val >= t) tmp.update((Pair){val % y, val});
      }
      if (tmp.x.mod >= 0) Max(min((long long)(t + tmp.x.mod) >> 1, sum - i), y);
      if (tmp.y.mod >= 0) {
        Max(min((long long)t + tmp.y.mod, sum - i - i), y);
        if (pre_num + (tmp.x.w < ky) > 1)
          Max(min((long long)t + tmp.x.mod, sum - i - i - 1), y);
      }
      ky = t;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
