#include <bits/stdc++.h>
using namespace std;
int f[200001];
int g[400001];
long long s[400001];
set<int> can;
long long ans = 0;
int main() {
  int n, maxi = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &f[i]);
  for (int i = 1; i <= n; i++) maxi = max(maxi, f[i]);
  for (int i = 1; i <= n; i++) g[f[i]]++;
  for (int i = 1; i <= 2 * maxi; i++) s[i] = s[i - 1] + g[i];
  for (int i = 1; i <= n; i++) can.insert(f[i]);
  for (auto it = can.begin(); it != can.end(); it++) {
    int now = *it;
    long long tmp = 0;
    for (int i = 1; i * now <= maxi; i++) {
      tmp += i * now * (s[(i + 1) * now - 1] - s[i * now - 1]);
    }
    ans = max(ans, tmp);
  }
  printf("%lld\n", ans);
  return 0;
}
