#include <bits/stdc++.h>
using namespace std;
long long add(long long a, long long b) {
  a %= 1000000007;
  b %= 1000000007;
  long long p = (a + b) % 1000000007;
  return (p + 1000000007) % 1000000007;
}
long long mul(long long a, long long b) {
  a %= 1000000007;
  b %= 1000000007;
  long long p = (a * b) % 1000000007;
  return (p + 1000000007) % 1000000007;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long i, j, n, a[200010], fre[200010] = {0}, suf[500010] = {0};
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    fre[a[i]]++;
  }
  for (i = 200000; i >= 0; i--) suf[i] = suf[i + 1] + fre[i];
  long long cnt = 0;
  i = 1;
  long long ma = 0;
  while (cnt != n) {
    while (!fre[i]) i++;
    long long sum = 0;
    for (j = (200000 / i) * i; j > 0; j -= i) sum += (suf[j] - suf[j + i]) * j;
    ma = max(ma, sum);
    cnt += fre[i];
    i++;
  }
  cout << ma << endl;
  return 0;
}
