#include <bits/stdc++.h>
using namespace std;
long long ara[400005], csum1[400005], csum2[400005];
int main() {
  int n;
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 0; i < n; i++)
    scanf("%lld", &ara[i]), sum += ara[i], csum1[ara[i]] += ara[i],
        csum2[ara[i]]++;
  for (int i = 1; i <= 400000; i++)
    csum1[i] += csum1[i - 1], csum2[i] += csum2[i - 1];
  sort(ara, ara + n);
  long long res = 0, lft = 0;
  for (int i = 0; i < n; i++) {
    long long s = 0;
    int x = ara[i];
    while (i < n && ara[i] == x) s += ara[i], i++;
    i--;
    long long temp = 0;
    for (int j = x; j <= 200000; j += x)
      temp += (csum1[j + x - 1] - csum1[j]) - (csum2[j + x - 1] - csum2[j]) * j;
    res = max(res, sum - temp - lft);
    lft += s;
  }
  printf("%lld\n", res);
  return 0;
}
