#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return b < a ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int oo = 0x3f3f3f3f;
const int maxabs = 1000100;
int n;
int cnt[maxabs + 5];
int pre0[maxabs + 5], pre1[maxabs + 5];
inline pair<int, int> find_best(int second, int lim) {
  int best0 = -1, best1 = -1;
  for (int i = second; i <= maxabs; i += second) {
    if (pre0[i] >= max(lim, i - second)) {
      if (!~best0 || pre0[i] % second > best0 % second)
        best1 = best0, best0 = pre0[i];
      else if (pre0[i] % second > best1 % second)
        best1 = pre0[i];
    }
    if (pre1[i] >= max(lim, i - second)) {
      if (pre1[i] % second > best1 % second) best1 = pre1[i];
    }
  }
  return make_pair(best0, best1);
}
inline bool check(int first, int second, const long long &sum) {
  pair<int, int> tmp = find_best(second, 2 * first);
  if (~tmp.first &&
      sum - tmp.first / second + (tmp.first - first * 2) / second >= first)
    return 1;
  tmp = find_best(second, first);
  if (~tmp.first && ~tmp.second &&
      sum - tmp.first / second - tmp.second / second +
              (tmp.first - first) / second + (tmp.second - first) / second >=
          first)
    return 1;
  return 0;
}
int main() {
  scanf("%d", &n);
  int Max0 = 0, Max1 = 0;
  for (int i = (0), i_end_ = (n); i < i_end_; ++i) {
    int first;
    scanf("%d", &first);
    if (first > Max0)
      Max1 = Max0, Max0 = first;
    else
      chkmax(Max1, first);
    ++cnt[first];
  }
  long long upperx = max(Max0 >> 1, Max1);
  int lst0 = -1, lst1 = -1;
  for (int i = (0), i_end_ = (maxabs + 1); i < i_end_; ++i) {
    pre0[i] = lst0;
    pre1[i] = lst1;
    if (cnt[i] == 1)
      lst1 = lst0, lst0 = i;
    else if (cnt[i] > 1)
      lst0 = lst1 = i;
  }
  for (int i = maxabs - 1; i >= 0; --i) cnt[i] += cnt[i + 1];
  long long ans = 0;
  for (int second = 2; second <= maxabs; ++second) {
    long long sum = 0;
    for (int i = second; i <= maxabs; i += second) {
      sum += cnt[i];
    }
    int Maxx =
        min(upperx, max(2LL, sum - (2 * sum + second + 1) / (second + 2)));
    for (int first = (Maxx), x_end_ = (Maxx + 3); first < x_end_; ++first)
      if (check(first, second, sum)) chkmax(ans, (long long)first * second);
  }
  printf("%lld\n", ans);
  return 0;
}
