#include <bits/stdc++.h>
using namespace std;
int n, a[200005], cnt[500005];
long long ans = 0, maxi = 0;
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", a + i);
      ++cnt[a[i]];
    }
    sort(a, a + n);
    cnt[0] = 0;
    for (int i = 1; i <= 500000; ++i) {
      cnt[i] += cnt[i - 1];
    }
    set<int> s;
    for (int i = 0; i < n; ++i) {
      if (s.count(a[i])) continue;
      s.insert(a[i]);
      int x = a[i];
      int y = x;
      ans = 0;
      while (y <= 200005) {
        ans += 1ll * y * (cnt[y + x - 1] - cnt[y - 1]);
        y += x;
      }
      maxi = max(ans, maxi);
    }
    cout << maxi << endl;
  }
}
