#include <bits/stdc++.h>
using namespace std;
long long n, mx;
long long ans;
long long ar[200005];
long long cnt[400005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    cnt[ar[i]]++;
    mx = max(mx, ar[i]);
  }
  for (int i = 1; i <= 2 * mx + 5; i++) cnt[i] += cnt[i - 1];
  sort(ar, ar + n);
  for (int i = 0; i < n; i++) {
    if (i && ar[i] == ar[i - 1]) continue;
    long long temp = 0;
    int j = ar[i];
    while (j + ar[i] <= 2 * mx + 5) {
      j += ar[i];
      temp += (cnt[j - 1] - cnt[j - 1 - ar[i]]) * (j - ar[i]);
    }
    ans = max(ans, temp);
  }
  cout << ans << endl;
  return 0;
}
