#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500010;
int A[MAXN];
int cnt[2 * MAXN];
vector<int> pv[2 * MAXN];
void updmx(int &mx1, int &mx2, int a) {
  mx2 = max(mx2, a);
  if (mx1 < mx2) swap(mx1, mx2);
}
void updans(long long &ans, int x, int y) {
  if (x >= 2 && y >= 2) ans = max(ans, (long long)x * y);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) {
    cnt[A[i]]++;
    if (pv[A[i]].size() < 2) pv[A[i]].push_back(A[i]);
  }
  for (int i = 1; i < 2 * MAXN; i++) {
    cnt[i] += cnt[i - 1];
    if (pv[i].empty()) {
      if (!pv[i - 1].empty()) pv[i].push_back(pv[i - 1][0]);
      if (pv[i - 1].size() > 1) pv[i].push_back(pv[i - 1][1]);
    } else if (pv[i].size() < 2 && !pv[i - 1].empty())
      pv[i].push_back(pv[i - 1][0]);
  }
  long long ans = 0;
  for (int y = 2; y < MAXN; y++) {
    int mx1 = -1, mx2 = -1;
    long long sum = 0;
    for (int k = 1; k * y < MAXN; k++)
      sum += (long long)(cnt[k * y + y - 1] - cnt[k * y - 1]) * k;
    for (int k = MAXN / y; k >= 0; k--) {
      if (mx1 >= 0)
        updans(ans, min(sum - k - 1, (long long)(k * y + y + mx1) / 2), y);
      if (mx2 >= 0) {
        updans(ans, min(sum - 2 * k - 2, (long long)k * y + y + mx2), y);
        updans(ans, min({sum - 2 * k - 1, (long long)k * y + mx1}), y);
      }
      int t = k * y + y - 1;
      if (!pv[t].empty() && pv[t][0] >= k * y) {
        if (mx1 >= 0) updans(ans, min(sum - 2 * k - 1, (long long)pv[t][0]), y);
        updmx(mx1, mx2, pv[t][0] - k * y);
      }
      if (pv[t].size() > 1 && pv[t][1] >= k * y)
        updmx(mx1, mx2, pv[t][1] - k * y);
      if (mx1 >= 0) updans(ans, min(sum - k, (long long)(k * y + mx1) / 2), y);
      if (mx2 >= 0) updans(ans, min(sum - 2 * k, (long long)k * y + mx2), y);
    }
  }
  cout << ans << "\n";
  return 0;
}
