#include <bits/stdc++.h>
using namespace std;
long long m, n, i, r, j, x, a[200003], t[200005], ans, ck[200003], d;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    ck[x] = 1;
    a[x]++;
  }
  for (i = 200000; i > 0; i--) t[i] += (t[i + 1] + a[i]);
  for (i = 1; i <= 200000; i++) {
    m = 0;
    if (ck[i])
      for (j = i; j <= 200000; j += i) {
        if (i + j > 200000)
          d = 0;
        else
          d = t[j + i];
        m += j * (t[j] - d);
      }
    ans = max(ans, m);
  }
  cout << ans;
}
