#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, mx;
int a[N], S[N];
long long ans;
long long DIF1(int x, int y) {
  int S1 = 0, S2 = 0;
  for (int i = (int)(0); i <= (int)(mx / y); i++) {
    int l = max(x, i * y);
    int r = min((i + 1) * y - 1, mx);
    if (l > r) continue;
    int m = min(x % y + i * y, mx + 1);
    S1 += S[m - 1] - S[l - 1];
    if (m <= r) S2 += S[r] - S[m - 1];
  }
  if (S1 + S2 < 2)
    return 1ll << 60;
  else
    return x / y * 2 + 2 - min(S2, 2);
}
long long DIF2(int x, int y) {
  x *= 2;
  int S1 = 0, S2 = 0;
  for (int i = (int)(0); i <= (int)(mx / y); i++) {
    int l = max(x, i * y);
    int r = min((i + 1) * y - 1, mx);
    if (l > r) continue;
    int m = min(x % y + i * y, mx + 1);
    S1 += S[m - 1] - S[l - 1];
    if (m <= r) S2 += S[r] - S[m - 1];
  }
  if (S1 + S2 < 1)
    return 1ll << 60;
  else
    return x / y + 1 - min(S2, 1);
}
void update(int y) {
  long long sum = 0;
  for (int i = (int)(1); i <= (int)(mx / y); i++) {
    int l = i * y, r = min(l + y - 1, mx);
    sum += 1ll * i * (S[r] - S[l - 1]);
  }
  int l = 2, r = mx, v = 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (sum - min(DIF1(mid, y), DIF2(mid, y)) >= mid)
      v = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  ans = max(ans, 1ll * v * y);
}
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n); i++) {
    scanf("%d", &a[i]);
    mx = max(mx, a[i]);
    S[a[i]]++;
  }
  for (int i = (int)(1); i <= (int)(mx); i++) S[i] += S[i - 1];
  for (int i = (int)(2); i <= (int)(mx); i++) update(i);
  printf("%lld\n", ans);
}
