#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using LD = long double;
void err() { cerr << "\033[39;0m" << endl; }
template <typename T, typename... A>
void err(T a, A... x) {
  cerr << a << ' ';
  err(x...);
}
const int N = 5e5 + 10;
int a[N], b[N], c[N];
LL ans = 0;
int n, mx = 0;
int max_below(int x) {
  if (x > mx) x = mx;
  return c[x];
}
pair<int, int> max_below_2(int x) {
  if (x > mx) x = mx;
  x = c[x];
  if (x == 0) return pair<int, int>(0, 0);
  if (b[x] - b[x - 1] > 1) return pair<int, int>(x, x);
  int y = c[x - 1];
  return pair<int, int>(x, y);
}
void add(pair<int, int> &p, int x) {
  if (x >= p.first) {
    p.second = p.first;
    p.first = x;
    return;
  }
  if (x > p.second) {
    p.second = x;
  }
}
void update(LL i, LL w) {
  if (w <= 1) return;
  ;
  ans = max(ans, w * i);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (decay<decltype(n)>::type i = (0), _i = (n); i < _i; ++i) {
    cin >> a[i];
    mx = max(mx, a[i]);
    ++b[a[i]];
  }
  for (decay<decltype(mx + 1)>::type i = (1), _i = (mx + 1); i < _i; ++i) {
    c[i] = b[i] > 0 ? i : c[i - 1];
    b[i] += b[i - 1];
  }
  for (decay<decltype(mx + 1)>::type i = (1), _i = (mx + 1); i < _i; ++i) {
    LL width = 0;
    LL mk = mx / i;
    for (int j = i - 1, k = 1; j <= mx; j += i, ++k) {
      int rb = min(j + i, mx);
      width += 1LL * k * (b[rb] - b[j]);
    }
    {
      int mm = 0;
      for (decay<decltype(mk)>::type k = (mk), _k = (-1); k > _k; --k) {
        int ki = i * k;
        int m = max_below(ki + i - 1);
        if (m >= ki) mm = max(mm, m % i);
        int now = ki + mm;
        LL x = now / 2;
        LL w = min(x, width - k);
        update(i, w);
        if (m == mx) continue;
        x = now / 2;
        w = min(x, width - k - 1);
        update(i, w);
      }
    }
    {
      pair<int, int> m2(-N, -N);
      int mm = 0;
      for (decay<decltype(mk)>::type k = (mk), _k = (-1); k > _k; --k) {
        int ki = i * k;
        auto pr = max_below_2(ki + i - 1);
        ;
        if (pr.first >= ki) add(m2, pr.first % i);
        if (pr.second >= ki) add(m2, pr.second % i);
        ;
        int m = min(m2.first, m2.second);
        LL x = ki + m;
        LL w = min(x, width - k - k);
        update(i, w);
        ;
        if (pr.first == mx) continue;
        if (b[mx] - b[ki + m2.first - 1] < 2) continue;
        x = ki + m2.first;
        w = min(x, width - k - k - 1);
        update(i, w);
        if (b[mx] - b[ki + i - 2] < 2) continue;
        x = ki + i - 1;
        w = min(x, width - k - k - 2);
        update(i, w);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
