#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, a[N];
int cnt[N];
long long sc[N];
long long sum;
long long divx(long long x, long long y) { return x / y + 1; }
long long ans;
int main() {
  scanf("%d", &n);
  for (int i = 1, B = n; i <= B; i++) scanf("%d", &a[i]), cnt[a[i]]++;
  sort(a + 1, a + n + 1);
  for (int i = 1, B = 1e6; i <= B; i++) sc[i] = sc[i - 1] + cnt[i];
  for (int y = 2, B = 5e5; y <= B; y++) {
    sum = 0;
    for (int i = 1, B = 5e5 / y; i <= B; i++)
      sum += (sc[i * y + y - 1] - (i == 0 ? 0 : sc[i * y - 1])) * i;
    if (sum == 0) continue;
    long long x = 0;
    for (long long l = 1, r = 5e5; l <= r;) {
      long long m = l + r >> 1;
      if (m <= sum - 2 * divx(m, y) + 2)
        x = m, l = m + 1;
      else
        r = m - 1;
    }
    x = min(x, (long long)a[n - 1]);
    for (int i = 0, B = 2; i <= B; i++) {
      if (x <= 1) break;
      int cnt1 = 0;
      for (int j = x / y, B = 5e5 / y; j <= B; j++)
        cnt1 += sc[j * y + y - 1] - sc[j * y + x % y - 1];
      long long t = sum - 2 * divx(x, y) + min(2, cnt1);
      if (x <= t) ans = max(ans, (long long)y * x);
      x--;
    }
  }
  for (int y = 2, B = 5e5; y <= B; y++) {
    sum = 0;
    for (int i = 1, B = 5e5 / y; i <= B; i++)
      sum += (sc[i * y + y - 1] - (i == 0 ? 0 : sc[i * y - 1])) * i;
    if (sum == 0) continue;
    long long x = 0;
    for (long long l = 1, r = 5e5; l <= r;) {
      long long m = l + r >> 1;
      if (m <= sum - divx(2 * m, y) + 1)
        x = m, l = m + 1;
      else
        r = m - 1;
    }
    x = min(x, (long long)a[n] / 2);
    for (int i = 0, B = 2; i <= B; i++) {
      if (x <= 1) break;
      int cnt1 = 0;
      long long c = 2 * x % y;
      for (int j = 2 * x / y, B = 5e5 / y; j <= B; j++)
        cnt1 += sc[j * y + y - 1] - sc[j * y + c - 1];
      long long t = sum - divx(2 * x, y) + min(1, cnt1);
      if (x <= t) ans = max(ans, (long long)y * x);
      x--;
    }
  }
  printf("%I64d\n", ans);
}
