#include <bits/stdc++.h>
using namespace std;
const int mo = 998244353, mo2 = 1e9 + 7;
const int N = 1e6 + 5, M = 5005, G = 505;
int n;
int a[N], s[N];
int mx, cmx;
long long ans;
void R(int &n) {
  char c;
  for (n = 0; (c = getchar()) < '0' || c > '9';)
    ;
  for (; c <= '9' && c >= '0'; c = getchar()) n = n * 10 + c - 48;
}
void P(long long n) {
  if (!n) putchar('0');
  int j = 0;
  char o[30];
  for (; n; n /= 10) o[++j] = n % 10 + 48;
  for (; j;) putchar(o[j--]);
  putchar('\n');
}
int ksm(int x, int y) {
  int t = 1;
  for (; y; y >>= 1, x = (long long)x * x % mo)
    if (y & 1) t = (long long)t * x % mo;
  return t;
}
bool cmp(int x, int y) { return x > y; }
void work(int y, long long ss, int x) {
  if (x < 2) return;
  x = min(x, cmx);
  ss -= (x + y - 1) / y * 2;
  int g = 0, xx = x % y;
  if (xx) {
    for (int i = x / y, _e = mx / y; i <= _e; ++i)
      g += s[(i + 1) * y - 1] - s[i * y + xx - 1];
  }
  g = min(g, 2);
  if (x <= ss + g) {
    ans = max(ans, (long long)x * y);
  }
}
void work2(int y, long long ss, int x, int xxx) {
  if (x < 2) return;
  x = min(x, mx);
  ss -= (x + y - 1) / y;
  int g = 0, xx = x % y;
  if (xx) {
    for (int i = x / y, _e = mx / y; i <= _e; ++i)
      g += s[(i + 1) * y - 1] - s[i * y + xx - 1];
  }
  g = min(g, 1);
  if (xxx <= ss + g) {
    ans = max(ans, (long long)xxx * y);
  }
}
int main() {
  R(n);
  for (int i = 1, _e = n; i <= _e; ++i) {
    R(a[i]), ++s[a[i]];
    if (a[i] > mx) {
      cmx = mx;
      mx = a[i];
    } else {
      if (a[i] > cmx) cmx = a[i];
    }
  }
  for (int i = 1, _e = 1e6; i <= _e; ++i) s[i] += s[i - 1];
  ans = 4;
  for (int y = 2, _e = mx; y <= _e; ++y) {
    long long ss = 0;
    for (int i = 1, _e = mx / y; i <= _e; ++i)
      ss += (long long)(s[i * y + y - 1] - s[i * y - 1]) * i;
    if (ss >= 2) {
      int xx = 0;
      if (n > 1) {
        for (int l = 2, r = mx, mi; mi = l + r >> 1, l <= r;)
          if (mi + ((mi + y - 1) / y) * 2 <= ss + 2)
            xx = mi, l = mi + 1;
          else
            r = mi - 1;
        xx = min(xx, cmx);
        for (int o = 0, _e = 4; o <= _e; ++o) work(y, ss, xx - o);
      }
      xx = 0;
      for (int l = 2, r = mx / 2, mi; mi = l + r >> 1, l <= r;)
        if (mi + ((mi * 2 + y - 1) / y) <= ss + 2)
          xx = mi, l = mi + 1;
        else
          r = mi - 1;
      for (int o = 0, _e = 3; o <= _e; ++o) work2(y, ss, (xx - o) * 2, xx - o);
    } else
      break;
  }
  cout << ans;
}
