#include <bits/stdc++.h>
using namespace std;
mt19937_64 gen;
const long long N = 5e5 + 15;
long long cnt[N], pref[N];
long long n;
inline long long get(long long l, long long r) {
  if (!l) return pref[r];
  return pref[r] - pref[l - 1];
}
long long sz[N];
inline long long calc(long long second) {
  long long res = 0;
  for (long long i = 0; i < N; i += second)
    res += get(i, min(N - 1, i + second - 1)) * (i / second);
  return res;
}
long long la[2][N];
inline long long one(long long first, long long second) {
  long long res = 1e18;
  for (long long i = 0; i < N; i += second) {
    long long r = min(N - 1, i + second - 1);
    if (la[0][r] >= first) {
      res = min(res, la[0][r] / second - (la[0][r] - first) / second);
    }
  }
  return res;
}
inline long long two(long long first, long long second) {
  vector<long long> res(2, 1e16);
  for (long long i = 0; i < N; i += second) {
    long long r = min(N - 1, i + second - 1);
    for (long long z : {0, 1}) {
      if (la[z][r] >= i && la[z][r] >= first) {
        long long cu = la[z][r] / second - (la[z][r] - first) / second;
        for (long long d : {0, 1}) {
          if (res[d] > cu) swap(res[d], cu);
        }
      }
    }
  }
  return res[0] + res[1];
}
inline bool f(long long first, long long second) {
  if (sz[second] - one(2 * first, second) >= first) return 1;
  if (sz[second] - two(first, second) >= first) return 1;
  return 0;
}
void run() {
  cin >> n;
  long long mx = 0;
  for (long long i = 0; i < n; i++) {
    long long first;
    cin >> first;
    mx = max(mx, first);
    cnt[first]++;
  }
  partial_sum(cnt, cnt + N, pref);
  long long a = -1, b = -1;
  for (long long i = 0; i < N; i++) {
    if (cnt[i]) {
      b = a;
      a = i;
    }
    if (cnt[i] >= 2) {
      b = i;
    }
    la[0][i] = a, la[1][i] = b;
  }
  vector<long long> ord(N - 2);
  iota((ord).begin(), (ord).end(), 2LL);
  shuffle((ord).begin(), (ord).end(), gen);
  long long res = 4;
  for (long long second : ord) {
    sz[second] = calc(second);
    if (f(max(2LL, res / second + 1), second)) {
      long long l = max(2LL, res / second + 1), r = N;
      while (r - l > 1) {
        long long m = (l + r) / 2;
        if (f(m, second))
          l = m;
        else
          r = m;
      }
      res = max(res, l * 1LL * second);
    }
  }
  cout << res;
}
signed main() {
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
  ios::sync_with_stdio(0);
  cin.tie(0);
  run();
}
