#include <bits/stdc++.h>
long long poww(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * poww(a * a % md, b / 2, md) % md
                      : poww(a * a % md, b / 2, md) % md));
}
using namespace std;
const int maxn = 5000 * 100 + 5;
const long long inf = 9223372036854775807;
const long long mod = 1e9 + 7;
long long n, a[maxn], cnt[maxn], sum, ans, mx, mark[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
    mark[a[i]] = 1;
    cnt[a[i]]++;
  }
  for (int i = 1; i < maxn; i++) {
    cnt[i] += cnt[i - 1];
  }
  for (long long i = 1; i <= mx; i++) {
    sum = 0;
    for (long long j = i; j <= mx; j += i) {
      sum += (cnt[j + i - 1] - cnt[j - 1]) * j;
    }
    if (mark[i]) ans = max(ans, sum);
  }
  cout << ans;
}
