#include <bits/stdc++.h>
const double eps = 1e-6;
using namespace std;
long long a[200005], dp[2 * 200005], arr[200005];
int main() {
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) arr[a[i]]++;
  for (int i = 200005; i >= 0; i--) dp[i] = dp[i + 1] + arr[i];
  long long ans = 0;
  for (int i = 1; i < 200005; i++) {
    if (!arr[i]) continue;
    long long res = 0;
    for (int j = i; j < 200005; j += i) res += (dp[j] - dp[j + i]) * j;
    ans = max(ans, res);
  }
  cout << ans << "\n";
  return 0;
}
