#include <bits/stdc++.h>
using namespace std;
int a[200005];
int sum[400005];
inline long long read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int main() {
  int n;
  scanf("%d", &n);
  int mx = -1;
  for (int i = 0; i < n; i++) {
    a[i] = read();
    sum[a[i]]++;
    if (mx < a[i]) mx = a[i];
  }
  for (int i = 1; i <= mx << 1; i++) {
    sum[i] += sum[i - 1];
  }
  sort(a, a + n);
  n = unique(a, a + n) - a;
  long long ans = -1;
  for (int i = 0; i < n; i++) {
    long long all = 0;
    if (sum[a[i]] - sum[a[i] - 1])
      for (int j = a[i]; j <= mx; j += a[i]) {
        all += 1LL * j * (sum[a[i] + j - 1] - sum[j - 1]);
      }
    if (ans < all) ans = all;
  }
  printf("%I64d\n", ans);
  return 0;
}
