#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  int h = a.back();
  for (int y = 2; y <= h; y++) {
    int t = h / y + 1;
    vector<int> sh(t + 1);
    long long all = 0;
    sh[t] = n;
    for (int i = t - 1; i >= 0; i--) {
      sh[i] = lower_bound(a.begin(), a.end(), y * i) - a.begin();
      all += (sh[i + 1] - sh[i]) * i;
    }
    vector<int> suff_max_1(t + 1, -1);
    vector<int> suff_max_2(t + 1, -1);
    for (int i = t - 1; i >= 0; i--) {
      int val_1 = -1, val_2 = -1;
      if (sh[i] < sh[i + 1]) {
        val_1 = a[sh[i + 1] - 1] % y;
      }
      if (sh[i] + 1 < sh[i + 1]) {
        val_2 = a[sh[i + 1] - 2] % y;
      }
      if (val_1 > suff_max_1[i + 1]) {
        suff_max_2[i] = max(suff_max_1[i + 1], val_2);
        suff_max_1[i] = val_1;
      } else {
        suff_max_2[i] = max(suff_max_2[i + 1], val_1);
        suff_max_1[i] = suff_max_1[i + 1];
      }
    }
    for (int k = 0; k < t; k++) {
      if (suff_max_1[k] == -1) continue;
      int x2 = k * y + suff_max_1[k];
      int x = min((long long)x2 / 2, all - k);
      if (x >= 2) {
        ans = max(ans, (long long)x * y);
      }
    }
    for (int k = 0; k < t; k++) {
      if (suff_max_2[k] == -1) continue;
      int x = y * k + suff_max_2[k];
      x = min((long long)x, all - 2 * k);
      if (x >= 2) {
        ans = max(ans, (long long)x * y);
      }
      x = y * k + suff_max_1[k];
      if (a.end() - lower_bound(a.begin(), a.end(), x) < 2) continue;
      x = min((long long)x, all - 2 * k - 1);
      if (x >= 2) {
        ans = max(ans, (long long)x * y);
      }
    }
  }
  cout << ans << endl;
}
