#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  map<long long, int> m;
  long long maxv = 0;
  scanf("%d", &n);
  long long num[n + 1], sum[n + 1];
  for (i = 1; i <= n; i++) scanf("%lld", &num[i]);
  sort(num + 1, num + n + 1);
  sum[0] = num[0] = 0;
  for (i = 1; i <= n; i++) sum[i] = num[i] + sum[i - 1];
  for (i = 1; i <= n; i++)
    if (sum[n] - sum[i - 1] <= maxv || m[num[i]])
      continue;
    else {
      int base = num[i], y = i;
      long long temp = 0;
      j = 1;
      do {
        j++;
        int prev = y;
        y = lower_bound(num + i, num + n + 1, j * base) - num;
        temp += 1LL * (j - 1) * base * (y - prev);
      } while (num[n] >= j * base);
      maxv = max(maxv, temp);
      m[num[i]] = 1;
    }
  printf("%lld\n", maxv);
  return 0;
}
