#include <bits/stdc++.h>
using namespace std;
long long cnt[200002 << 1], s[200002 << 1];
long long ans, k;
int main() {
  int n, i, j;
  scanf("%d", &n);
  for (int i = 1, x; i <= n; i++) scanf("%d", &x), cnt[x]++;
  for (i = 1; i <= 2 * 200002; i++) s[i] = s[i - 1] + cnt[i];
  for (i = 1; i <= 200002; i++) {
    if (!cnt[i]) continue;
    k = 0;
    for (j = i + i - 1; j <= 2 * 200002; j += i)
      k += 1ll * (s[j] - s[j - i]) * (j - i + 1);
    ans = max(ans, k);
  }
  cout << ans << endl;
  return 0;
}
