#include <bits/stdc++.h>
using namespace std;
template <typename T>
void debug_out(T t) {
  cerr << t;
}
template <typename A, typename B>
void debug_out(pair<A, B> u) {
  cerr << "(" << u.first << " " << u.second << ")";
}
template <typename T>
void debug_out(vector<T> t) {
  int sz = t.size();
  for (int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if (i != sz - 1) cerr << ", ";
  }
}
template <typename T>
void debug_out(vector<vector<T>> t) {
  int sz = t.size();
  for (int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if (i != sz - 1) cerr << endl;
  }
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  debug_out(H);
  cerr << " ";
  debug_out(T...);
}
int n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int M = a.back() + 1;
  vector<int> to(M);
  for (int i = 1; i < M; i++) {
    to[i] = to[i - 1];
    while (to[i] < n && a[to[i]] < i) to[i]++;
  }
  long long res = 0;
  auto get = [&](int y, long long c, int ll, int rr) {
    if (c < 0) {
      return -1LL;
    }
    int s = c % y;
    if (s <= rr && s >= ll) {
      return c;
    }
    long long lc = y * (c / y) + ll;
    if (lc > c) lc -= y;
    long long rc = y * (c / y) + rr;
    if (rc > c) rc -= y;
    return max(-1LL, max(lc, rc));
  };
  for (int y = 2; y < M; y++) {
    long long sum = 0;
    vector<int> pt;
    for (int j = 0; j < M; j += y) {
      int l = to[j];
      int r = (j + y < M ? to[j + y] - 1 : n - 1);
      if (r < l) continue;
      sum += 1LL * (r - l + 1) * j / y;
      if (r > l) pt.push_back(a[r - 1]);
      pt.push_back(a[r]);
    }
    int sz = pt.size();
    vector<pair<int, int>> dt(sz);
    for (int i = sz - 1; i > -1; i--) {
      dt[i].first = pt[i] % y;
      if (i < sz - 1) {
        dt[i] = dt[i + 1];
        if (dt[i].first > (pt[i] % y))
          dt[i].second = max(dt[i].second, pt[i] % y);
        else {
          swap(dt[i].first, dt[i].second);
          dt[i].first = pt[i] % y;
        }
      }
    }
    auto calc = [&](long long s) {
      if (s < 0) return -1LL;
      long long lo = 0, hi = sum + 1;
      while (hi - lo > 1) {
        long long mid = (hi + lo) >> 1;
        if (s - 2 * (mid / y) >= mid)
          lo = mid;
        else
          hi = mid;
      }
      return lo;
    };
    long long sa = calc(sum);
    long long sb = calc(sum - 1);
    long long sc = calc(sum - 2);
    for (int i = sz - 1; i > -1; i--) {
      int sf = dt[i].first, ss = dt[i].second;
      long long x = get(y, min(1LL * pt[i], sa), 0, ss);
      if (i == sz - 1) goto A;
      if (x > 1) res = max(res, x * y);
      if (ss < sf && sum > 0) {
        x = get(y, min(1LL * pt[i], sb), ss + 1, sf);
        if (x > 1) res = max(res, x * y);
      }
      if (sf < y - 1 && sum > 0) {
        x = get(y, min(1LL * pt[i], sc), sf + 1, y - 1);
        if (x > 1) res = max(res, x * y);
      }
    A:;
      x = get(y, min(1LL * pt[i] / 2, sa), 0, sf / 2);
      if (x > 1) res = max(res, x * y);
      if ((sf + y) / 2 < y && (sf / 2) + 1 <= (sf + y) / 2 && sum > 0) {
        x = get(y, min(1LL * pt[i] / 2, sb), (sf / 2) + 1, (sf + y) / 2);
        if (x > 1) res = max(res, x * y);
        if ((sf + y) / 2 < y - 1 && sum > 0) {
          x = get(y, min(1LL * pt[i] / 2, sc), (sf + y) / 2 + 1, y - 1);
          if (x > 1) res = max(res, x * y);
        }
      }
    }
  }
  cout << res;
  return 0;
}
