#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
template <class T>
inline void umin(T &x, T y) {
  x = x < y ? x : y;
}
template <class T>
inline void umax(T &x, T y) {
  x = x > y ? x : y;
}
inline unsigned int R() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
const int N = 605000;
int n, a[N], mx, buc[N], lim = 500000, qz[N];
long long cnt[N], res;
inline void ck(int x, int y) {
  if (1LL * x * y <= res || x > mx || x <= 1 || y <= 1) return;
  if (a[n - 1] >= x) {
    int res1 = 0, r = x % y, L = x;
    for (register int i = (lim / y); i >= (0); i--)
      if (max(i * y + r, L) <= min(i * y + y - 1, lim)) {
        res1 += qz[min(i * y + y - 1, lim)] -
                (max(i * y + r, L) - 1 >= 0 ? qz[max(i * y + r, L) - 1] : 0);
      }
    umin(res1, 2);
    if (cnt[y] - 2 * (x / y) - (2 - res1) >= x) {
      res = 1LL * x * y;
      return;
    }
  }
  if (a[n] >= 2 * x) {
    int res1 = 0, r = 2 * x % y, L = 2 * x;
    for (register int i = (lim / y); i >= (0); i--)
      if (max(i * y + r, L) <= min(i * y + y - 1, lim)) {
        res1 += qz[min(i * y + y - 1, lim)] -
                (max(i * y + r, L) - 1 >= 0 ? qz[max(i * y + r, L) - 1] : 0);
      }
    if (cnt[y] - (2 * x / y) - (!res1) >= x) {
      res = 1LL * x * y;
      return;
    }
  }
}
int main() {
  read(n);
  for (register int i = (1); i <= (n); i++) read(a[i]), buc[a[i]]++;
  sort(a + 1, a + n + 1);
  mx = max(a[n] / 2, a[n - 1]);
  for (register int i = (1); i <= (lim); i++) qz[i] = qz[i - 1] + buc[i];
  for (register int y = (1); y <= (lim); y++)
    for (register int i = (lim / y); i >= (1); i--)
      cnt[y] += 1LL * i * (qz[min(lim, (i + 1) * y - 1)] - qz[i * y - 1]);
  for (register int y = (1); y <= (lim); y++) {
    int L = 0, R = mx, ans = -1;
    while (L <= R) {
      int x = (L + R) >> 1;
      if (cnt[y] - 2LL * (x / y + 1) >= x)
        ans = x, L = x + 1;
      else
        R = x - 1;
    }
    if (ans >= 2 && y >= 2) umax(res, 1LL * ans * y);
    ck(ans + 1, y);
    ck(ans + 2, y);
  }
  cout << res;
  return 0;
}
