#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
long long mpe(long long base, long long exponent, long long modulus) {
  long long result = 1;
  while (exponent > 0) {
    if (exponent % 2 == 1) result = result * base % modulus;
    exponent = exponent >> 1;
    base = base * base % modulus;
  }
  return result;
}
long long arr[200005], pre[200005], pos[200005], cnt[200005];
vector<long long> vec;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  ;
  long long n;
  cin >> n;
  for (long long i = 1; i < n + 1; ++i) {
    cin >> arr[i];
    cnt[arr[i]]++;
  }
  sort(arr, arr + n + 1);
  for (long long i = 1; i < 200005; ++i) pre[i] = pre[i - 1] + cnt[i];
  for (long long i = 1; i < n + 1; ++i) {
    if (pos[arr[i]] == 0) {
      pos[arr[i]] = i;
      vec.push_back(arr[i]);
    }
  }
  long long ghata = 0, po, tgh, nu;
  for (long long i = 0; i < vec.size(); ++i) {
    nu = vec[i];
    tgh = 0;
    for (long long k = 200003 - (200003 % nu); k >= nu; k -= nu) {
      tgh += k * (pre[((k + nu - 1 > 200005) ? 200004 : (k + nu - 1))] -
                  pre[k - 1]);
    }
    ghata = max(ghata, tgh);
  }
  cout << ghata;
  return 0;
}
