#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
using ll = long long;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 5;
const int N = 2e5;
int n;
int f[maxn];
int have[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    f[x]++;
    have[x] = 1;
  }
  for (int i = N; i >= 0; i--) {
    f[i] += f[i + 1];
  }
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    if (have[i]) {
      ll tot = 0;
      ll prev = 0;
      for (int j = N / i * i; j >= i; j -= i) {
        ll count = f[j] - prev;
        tot += count * j;
        prev = f[j];
      }
      ans = max(ans, tot);
    }
  }
  cout << ans << endl;
  return 0;
}
