#include <bits/stdc++.h>
using namespace std;
long long freq[200005];
int main() {
  long long a, b, c, d, e, f, g, h, i, j, k;
  scanf("%lld", &a);
  memset(freq, 0, sizeof freq);
  for (b = 1; b <= a; b++) {
    scanf("%lld", &c);
    freq[c]++;
  }
  freq[0] = 0;
  for (b = 1; b <= 200000; b++) {
    freq[b] += freq[b - 1];
  }
  for (b = 1, f = 0; b <= 200000; b++) {
    if (freq[b] - freq[b - 1] == 0) continue;
    e = 0;
    for (c = b - 1, d = b * 2 - 1; c <= 200000; c += b, d += b) {
      d = min(d, 200000LL);
      e += (freq[d] - freq[c]) * (c + 1);
    }
    f = max(e, f);
  }
  printf("%lld\n", f);
  return 0;
}
