#include <bits/stdc++.h>
using namespace std;
int v[200005], sp[200005];
int main() {
  int i, n, j, st, dr;
  long long sum, maxsum = -1;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &v[i]);
    ++sp[v[i]];
  }
  for (i = 1; i < 200005; ++i) sp[i] += sp[i - 1];
  for (i = 1; i < 200005; ++i) {
    if (sp[i] != sp[i - 1]) {
      sum = 0;
      for (j = i; j < 200005; j += i) {
        st = j;
        dr = min(200000, st + i - 1);
        sum += 1LL * (sp[dr] - sp[st - 1]) * st;
      }
      maxsum = max(maxsum, sum);
    }
  }
  cout << maxsum;
  return 0;
}
