#include <bits/stdc++.h>
using namespace std;
int inf = 1000000005;
long long int llinf = 1000000000000000005LL;
long long int mod = 1000000007;
int dx[] = {1, 1, -1, -1};
int dy[] = {1, -1, 1, -1};
vector<bool> isprime;
vector<int> primes;
void seive(int n, bool wantlist = true) {
  isprime.resize(n + 1, true);
  isprime[0] = isprime[1] = false;
  int sq = sqrt(n + 1);
  for (int i = 2; i < sq + 1; i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= n; j += i) isprime[j] = false;
    }
  }
  for (int i = 2; wantlist && i <= n; i++) {
    if (isprime[i]) primes.push_back(i);
  }
}
template <class T>
inline T gcd(T a, T b) {
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
inline long long int bexp(long long int x, long long int n) {
  long long int res = 1;
  x %= mod;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
int N = 0, max_a = 200100;
vector<long long int> cnt(max_a), pc(max_a);
int main() {
  int n;
  scanf("%d", &n);
  ;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    ;
    cnt[x]++;
    N = max(N, x);
  }
  for (int i = 1; i < max_a; i++) pc[i] = pc[i - 1] + cnt[i];
  long long int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (cnt[i]) {
      long long int pre = pc[i], temp = i * cnt[i], j;
      for (j = 2 * i; j < max_a; j += i) {
        temp += (j - i) * (pc[j - 1] - pre);
        pre = pc[j - 1];
      }
      temp += (j - i) * (pc[max_a - 1] - pre);
      ans = max(ans, temp);
    }
  }
  printf("%lld\n", ans);
  ;
}
