#include <bits/stdc++.h>
using namespace std;
long long int i, j, p, d, n, m, total, k, ok, a, b, c, op, maxi, rasp, m1, m2,
    p1, p2, rez, modu = 1000000007, cul[200005], mini;
string s;
int v[200005], f[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a;
    f[a] = 1;
    v[a]++;
  }
  for (i = 200000 - 1; i > 0; i--) {
    v[i] += v[i + 1];
  }
  for (i = 1; i <= 200000; i++) {
    if (f[i]) {
      a = 200000 / i * i;
      b = v[a] * a;
      for (a = a - i; a >= i; a -= i) {
        b += (v[a] - v[a + i]) * a;
      }
      maxi = max(maxi, b);
    }
  }
  cout << maxi;
  return 0;
}
