#include <bits/stdc++.h>
const long long INF = (long long)1e18 + 123;
const int inf = (int)1e9 + 123;
const int mod = 1e9 + 7;
using namespace std;
int n, a[200011];
int f[200011];
bool u[200011];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    f[a[i]]++;
  }
  for (int i = 200000; i >= 1; i--) {
    f[i] += f[i + 1];
  }
  sort(a + 1, a + 1 + n);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (u[a[i]]) continue;
    int x = 200000 / a[i];
    long long cnt = 0, last = 0;
    for (int j = x * a[i]; j >= a[i]; j -= a[i]) {
      u[j] = 1;
      cnt += (f[j] - last) * j;
      last = f[j];
    }
    ans = max(ans, cnt);
  }
  cout << ans;
  return 0;
}
