#include <bits/stdc++.h>
using namespace std;
template <typename U, typename V>
void Min(U &a, const V &b) {
  if (a > b) a = b;
}
template <typename U, typename V>
void Max(U &a, const V &b) {
  if (a < b) a = b;
}
template <typename U, typename V>
void add(U &a, const V &b) {
  a = (a + b) % 998244353;
}
template <typename U>
U gcd(U a, U b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a >= b)
    return gcd(a % b, b);
  else
    return gcd(a, b % a);
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % 998244353;
    a = 1LL * a * a % 998244353;
    b >>= 1;
  }
  return ans;
}
int cnt[500005], pr[500005];
int main() {
  int T, n, m, i, j, k, ca = 0, K;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &k);
    cnt[k]++;
  }
  for (int i = 1; i < 500005; i++) {
    if (cnt[i])
      pr[i] = i;
    else
      pr[i] = pr[i - 1];
  }
  for (int i = 1; i < 500005; i++) cnt[i] += cnt[i - 1];
  long long ans = 0;
  for (int second = 2; second < 500005; second++) {
    long long sum = 0;
    int mx = 0;
    for (int i = second, j = 1; i < 500005; i += second, j++) {
      k = min(500005, i + second);
      sum += 1LL * (cnt[k - 1] - cnt[i - 1]) * j;
    }
    if (sum == 0) break;
    k = (500005 - 1) % second;
    int r = 500005 - 1 - k;
    for (int i = r; i >= 0; i -= second) {
      k = min(500005, i + second);
      K = cnt[k - 1] - (i ? cnt[i - 1] : 0);
      if (K == 0) continue;
      if (K >= 2) {
        int p = pr[k - 1], q = p;
        if (cnt[p] - cnt[p - 1] == 1) q = pr[p - 1];
        if (q >= i) {
          if (mx % second > p % second) {
            p = mx;
          }
          long long w = sum - q / second - p / second;
          long long first =
              min((long long)q, (w * second + p + q) / (2 + second));
          if (first >= 2 &&
              w + (p - first) / second + (q - first) / second >= first) {
            Max(ans, first * second);
          } else {
            first--;
            if (first <= q && first >= 2 &&
                w + (p - first) / second + (q - first) / second >= first)
              Max(ans, first * second);
          }
        }
      }
      if (mx) {
        int q = pr[k - 1], p = mx;
        long long w = sum - q / second - p / second;
        long long first =
            min((long long)q, (w * second + p + q) / (2 + second));
        if (first >= 2 &&
            w + (p - first) / second + (q - first) / second >= first) {
          Max(ans, first * second);
        } else {
          first--;
          if (first <= q && first >= 2 &&
              w + (p - first) / second + (q - first) / second >= first)
            Max(ans, first * second);
        }
      }
      K = pr[k - 1];
      if (mx % second < K % second || (mx % second == K % second && mx < K))
        mx = K;
      long long w = sum - K / second;
      long long first = min(K / 2LL, (w * second + K) / (2 + second));
      if (first >= 2 && w + (K - 2 * first) / second >= first) {
        Max(ans, first * second);
      } else {
        first--;
        if (2 * first <= K && first >= 2 &&
            w + (K - 2 * first) / second >= first)
          Max(ans, first * second);
      }
    }
  }
  printf("%lld\n", ans);
}
