#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int sum[N], a[N];
int main() {
  int n, x;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x, a[x]++;
  for (int i = 1; i <= 200000; i++) sum[i] = sum[i - 1] + a[i];
  long long ans = 0;
  for (int i = 1; i <= 200000; i++) {
    if (a[i]) {
      long long s = 0;
      for (int j = 0; j <= 200000; j += i) {
        int nex = min(200000, j + i - 1);
        if (j != 0) s += (long long)(sum[nex] - sum[j - 1]) * j;
      }
      ans = max(ans, s);
    }
  }
  cout << ans << endl;
  return 0;
}
