#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200000 + 10;
long long n, a[MAX_N], ans;
set<pair<long long, long long> > s;
bool mark[MAX_N];
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) s.insert(make_pair(a[i], i));
  while (s.size() > 0) {
    pair<long long, long long> u = *s.begin();
    s.erase(s.begin());
    if (mark[u.first]) continue;
    mark[u.first] = true;
    if (s.size() == 0) {
      ans = max(ans, u.first);
      break;
    }
    long long MAX = u.first;
    for (long long i = 1; i * u.first < MAX_N; i++) {
      set<pair<long long, long long> >::iterator l =
          s.lower_bound(make_pair(i * u.first, 0));
      set<pair<long long, long long> >::iterator h =
          s.lower_bound(make_pair((i + 1) * u.first, 0));
      if (l == h) continue;
      h--;
      if (l == s.end()) break;
      MAX += ((*h).second - (*l).second + 1) * (i * u.first);
    }
    ans = max(MAX, ans);
  }
  printf("%lld", ans);
}
