#include <bits/stdc++.h>
using namespace std;
long long debug;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
const long long N = 5e5 + 28;
long long n, a[N], apr[N], sum[N], pre[N], mx;
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) {
    a[i] = read();
    apr[a[i]]++;
    mx = max(mx, a[i]);
  }
  apr[0] = 19260817;
  for (long long i = 1; i <= mx; i++) {
    sum[i] = sum[i - 1] + apr[i];
    if (apr[i])
      pre[i] = i;
    else
      pre[i] = pre[i - 1];
  }
  long long ans = 0;
  for (long long y = 2; y <= mx; y++) {
    long long tot = 0;
    for (long long m = y; m <= mx; m += y)
      tot += (sum[((mx) < (m + y - 1) ? (mx) : (m + y - 1))] - sum[m - 1]) *
             (m / y);
    long long fk1 = -1, fk2 = -1;
    for (long long k = mx / y; k >= 0; k--) {
      long long base = k * y,
                m = ((k * y + y) < (mx + 1) ? (k * y + y) : (mx + 1));
      long long p = pre[m - 1];
      if (p >= base) {
        fk2 = max(p % y, fk2);
        if (fk2 > fk1) swap(fk1, fk2);
        if (apr[p] == 1) p = pre[p - 1];
        if (p >= base) {
          fk2 = max(p % y, fk2);
          if (fk2 > fk1) swap(fk1, fk2);
        }
      }
      if (~fk1) {
        long long x =
            ((tot - k) < ((base + fk1) >> 1) ? (tot - k) : ((base + fk1) >> 1));
        if (x >= 2) ans = max(ans, x * y);
      }
      if (~fk2) {
        long long x =
            ((tot - k - k) < (base + fk2) ? (tot - k - k) : (base + fk2));
        if (x >= 2) ans = max(ans, x * y);
        if (sum[mx] - sum[base + fk1 - 1] >= 2) {
          long long x = ((tot - k - k - 1) < (base + fk1) ? (tot - k - k - 1)
                                                          : (base + fk1));
          if (x >= 2) ans = max(ans, x * y);
        }
      }
    }
  }
  printf("%I64d", ans);
  return 0;
}
