#include <bits/stdc++.h>
using namespace std;
inline int read(void) {
  int sum = 0, sign = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  return sum * sign;
}
const int maxn = 2e5 + 5;
const long long N = 4e10 + 5;
int num[2 * maxn + 5];
int sum[2 * maxn + 5];
int main() {
  int n = read();
  vector<int> v;
  for (int i = 1; i <= n; i++) v.push_back(read());
  sort(v.begin(), v.end());
  int r = v[n - 1];
  for (int i = 0; i < n; i++) num[v[i]]++;
  for (int i = 1; i <= 2 * maxn; i++) sum[i] = sum[i - 1] + num[i];
  long long ans = 0;
  for (int i = 0; i < n; i += num[v[i]]) {
    int p = 2;
    long long tmp = 0;
    while (p * v[i] <= r) {
      tmp +=
          1ll * v[i] * (p - 1) * (sum[v[i] * p - 1] - sum[v[i] * (p - 1) - 1]);
      p++;
    }
    tmp += 1ll * v[i] * (p - 1) * (sum[v[i] * p - 1] - sum[v[i] * (p - 1) - 1]);
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
