#include <bits/stdc++.h>
using namespace std;
long long n, ans;
vector<long long> a;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  set<long long> s;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    s.insert(x);
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  for (auto it : s) {
    long long x = it;
    long long t = 0, p = 0;
    for (int j = x; j <= a[n - 1] + x; j += x) {
      auto y = lower_bound(a.begin(), a.end(), j);
      int k = (y - a.begin());
      t += (j / x - 1) * (k - p);
      p = k;
    }
    ans = max(ans, t * x);
  }
  cout << ans;
}
