#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 100;
const long long inF = 1e16;
int n, a[N], cnt[N << 2], ps[N << 2];
long long ans;
vector<int> all;
struct DEQUE {
  int sz, deq[2];
  void push_back(int x) {
    if (sz < 2)
      deq[sz++] = x;
    else {
      deq[0] = deq[1];
      deq[1] = x;
    }
  }
  void pop_front() {
    deq[0] = deq[1];
    sz--;
  }
  int operator[](int x) { return deq[x]; }
} deq[N << 1];
void input_ready() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  for (int i = 1; i < 4 * N; i++) {
    ps[i] = cnt[i] + ps[i - 1];
    if (cnt[i]) all.push_back(i);
  }
}
void go(int len) {
  for (int i = 0; i <= N / len; i++) {
    deq[i].sz = 0;
    int l = len * i, r = len * (i + 1);
    int dex = lower_bound(all.begin(), all.end(), r) - all.begin();
    for (int j = max(0, dex - 2); j < all.size() && all[j] < r; j++)
      if (all[j] >= l)
        for (int x = 0; x < min(2, cnt[all[j]]); x++) deq[i].push_back(all[j]);
  }
}
long long mx, mx1, mx2;
long long CNT;
void ADD(long long y, long long last) {
  mx = max(mx, last % y);
  long long help = min(last / 2, (CNT * y + mx) / (y + 2));
  for (long long x = help; x >= help - 3 && x >= 2; x--)
    if (2 * x <= last && CNT - max(0LL, (2 * x - mx + y - 1) / y) >= x) {
      ans = max(ans, x * y);
      break;
    }
  mx2 = max(mx2, last % y);
  if (mx2 > mx1) swap(mx1, mx2);
  help = min(last, (CNT * y + mx1 + mx2) / (y + 2));
  for (long long x = help; x >= help - 3 && x >= 2; x--)
    if (x <= last && CNT - max(0LL, (x - mx1 + y - 1) / y) -
                             max(0LL, (x - mx2 + y - 1) / y) >=
                         x) {
      ans = max(ans, x * y);
      break;
    }
}
void check(long long y) {
  CNT = 0;
  for (int i = 1; i <= N / y; i++)
    CNT += i * (ps[y * (i + 1) - 1] - ps[y * i - 1]);
  mx = mx1 = mx2 = -inF;
  for (int i = N / y; ~i; i--)
    for (int j = deq[i].sz - 1; j >= 0; j--) ADD(y, deq[i][j]);
}
void solve() {
  go(1);
  for (int i = 2; i < N; i++) {
    go(i);
    check(i);
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  input_ready();
  solve();
  cout << ans;
}
