#include <bits/stdc++.h>
using namespace std;
mt19937 bruh(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rofl(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e6 + 2;
const int M = 1e6;
const int mod = 0;
const int inf = 2e9 + 3;
const long long INF = 1e18;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
void files() {
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
}
int n, a[N], pr[N], mx[N], was[N];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    pr[a[i]]++;
    was[a[i]]++;
  }
  for (int i = 1; i <= M; ++i) {
    if (pr[i])
      mx[i] = i;
    else
      mx[i] = mx[i - 1];
    pr[i] += pr[i - 1];
  }
  mx[0] = -inf;
  long long ans = 0;
  for (int y = 2; y <= M; ++y) {
    int col = 0;
    for (int c = y - 1; c <= M; c += y)
      col += (c / y) * (pr[c] - pr[max(0, c - y)]);
    int l = 2, r = M;
    while (l <= r) {
      int m = l + r >> 1;
      int mn = inf, cnt = 0;
      for (int c = y - 1; c <= M; c += y) {
        if (mx[c] >= max(m, c - y + 1) && mx[mx[c] - 1] >= max(m, c - y + 1))
          mn = min(mn, (mx[mx[c] - 1] / y) - ((mx[mx[c] - 1] - m) / y));
        if (mx[c] >= max(m, c - y + 1) && was[mx[c]] > 1)
          mn = min(mn, (mx[c] / y) - ((mx[c] - m) / y));
        if (mx[c] >= max(m, c - y + 1)) {
          cnt = max(cnt, col - mn - ((mx[c] / y) - ((mx[c] - m) / y)));
          mn = min(mn, (mx[c] / y) - ((mx[c] - m) / y));
          if (mx[c] >= 2 * m)
            cnt = max(cnt, col - ((mx[c] / y) - ((mx[c] - 2 * m) / y)));
        }
      }
      if (cnt >= m) {
        ans = max(ans, 1LL * m * y);
        l = m + 1;
      } else
        r = m - 1;
    }
  }
  cout << ans << '\n';
}
