#include <bits/stdc++.h>
using namespace std;
const int N = 500005, INF = 0X3F3F3F3F;
int n, a[N], cnt[N], sum[N], pre[N];
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) scanf("%d", &a[i]), ++cnt[a[i]];
  for (int i = (1); i <= (N - 1); ++i)
    pre[i] = cnt[i] ? i : pre[i - 1], sum[i] = sum[i - 1] + cnt[i];
  long long ans = 0;
  for (int y = (2); y <= (N - 1); ++y) {
    long long tt = 0;
    for (int i = y; i < N; i += y) {
      tt += 1LL * (sum[min(i + y - 1, N - 1)] - sum[i - 1]) * (i / y);
    }
    pair<int, int> mx{~INF, ~INF}, smx{~INF, ~INF};
    auto put = [&](int k1) {
      pair<int, int> cur{k1 % y, k1};
      if (mx < cur)
        smx = mx, mx = cur;
      else if (smx < cur)
        smx = cur;
    };
    for (int i = N / y * y; i >= 0; i -= y) {
      int num = pre[min(N - 1, i + y - 1)];
      int can = (mx.first >= 0) + (smx.first >= 0);
      if (num >= i) {
        put(num);
        if (cnt[num] == 1) num = pre[num - 1];
        if (num >= i) {
          put(num);
        }
      }
      if (mx.first >= 0) {
        int x = min((long long)(i + mx.first) / 2, tt - (i / y));
        if (x > 1) ans = max(ans, 1LL * x * y);
      }
      if (smx.first >= 0) {
        int x = min((long long)i + smx.first, tt - 2 * (i / y));
        if (x > 1) ans = max(ans, 1LL * x * y);
        if (can + (mx.second <= i + y - 1) > 1) {
          x = min((long long)i + mx.first, tt - 2 * (i / y) - 1);
          if (x > 1) ans = max(ans, 1LL * x * y);
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
