#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
int n, m, a[maxn], sum[maxn], pre[maxn];
long long ans;
inline int getsum(int l, int r) { return sum[min(r, m)] - sum[l ? l - 1 : 0]; }
inline void upd(long long x, long long y) {
  if (x >= 2 && y >= 2) ans = max(ans, x * y);
}
inline pair<int, int> merge(const pair<int, int> &a, const int &b) {
  return pair<int, int>(max(a.first, b), max(a.second, min(a.first, b)));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]), sum[a[i]]++, m = max(m, a[i]);
  for (int i = 1; i <= m; i++)
    sum[i] += sum[i - 1], pre[i] = (sum[i] > sum[i - 1]) ? i : pre[i - 1];
  for (int y = 2; y <= m; y++) {
    pair<int, int> p = pair<int, int>(-1, -1);
    long long sumy = 0;
    for (int i = 0, j = 0; i <= m; i += y, j++)
      sumy += (long long)getsum(i, i + y - 1) * j;
    for (int l = (m / y) * y, r = m + 1, t = m / y; l >= 0;
         r = l, l -= y, t--) {
      int tmp = (p.first >= 0) + (p.second >= 0), v = pre[r - 1];
      if (v >= l) {
        p = merge(p, v % y);
        if (getsum(v, v) == 1) {
          v = pre[v - 1];
          if (v >= l) p = merge(p, v % y);
        } else
          p = merge(p, v % y);
      }
      v = pre[r - 1];
      if (v >= l && p.first == v % y) tmp++;
      if (p.first >= 0) {
        long long x = (l + p.first) / 2, remy = sumy - t;
        upd(min(x, remy), y);
      }
      if (p.second >= 0) {
        long long x = l + p.second, remy = sumy - t * 2;
        upd(min(x, remy), y);
        if (tmp >= 2) {
          x = l + p.first, remy--;
          upd(min(x, remy), y);
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
