#include <bits/stdc++.h>
using namespace std;
long long int a[200111];
long long int mp[400011];
long long int f[200001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, i, j, k, l, r, x, y, q, n;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
    f[a[i]]++;
  }
  for (i = 399999; i >= 0; i--) {
    mp[i] = mp[i + 1] + mp[i];
  }
  long long int ans = 0;
  for (i = 1; i <= 200000; i++) {
    if (f[i] == 0) continue;
    long long int c = 0;
    long long int ans1 = 0;
    for (j = i; j <= (400000 - i); j += i) {
      c++;
      ans1 = ans1 + ((mp[j] - mp[j + i]) * i * c);
    }
    ans = max(ans, ans1);
  }
  cout << ans;
  return 0;
}
