#include <bits/stdc++.h>
using namespace std;
const int N = 400005;
const long long inf = 1e18;
int n, x;
long long cnt[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    ++cnt[x];
  }
  for (int i = 1; i < N; ++i) cnt[i] += cnt[i - 1];
  long long result = 0;
  for (int i = 1; i < N; ++i) {
    if (cnt[i] - cnt[i - 1] > 0) {
      long long cur = (cnt[i] - cnt[i - 1]) * i;
      for (int j = 2 * i; j < N; j += i) {
        cur += (cnt[j - 1] - cnt[j - i]) * (j - i) + (cnt[j] - cnt[j - 1]) * j;
      }
      result = max(result, cur);
    }
  }
  cout << result << endl;
  return 0;
}
