#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int n;
vector<long long> f(200100, 0);
vector<long long> cf(200100, 0);
long long rangeSum(int l, int r) {
  long long sec = 0;
  if (r >= 200100) {
    sec = n;
  } else {
    sec = cf[r - 1];
  }
  return sec - cf[l - 1];
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    f[a]++;
  }
  cf[0] = f[0];
  for (int i = 0; i < 200100; i++) {
    cf[i + 1] = cf[i] + f[i + 1];
  }
  long long best = 0;
  for (int i = 1; i < 200100; i++) {
    if (f[i] == 0) continue;
    long long sum = 0;
    for (int j = i; j < 200100; j += i) {
      sum += j * rangeSum(j, j + i);
    }
    best = max(best, sum);
  }
  cout << best << endl;
}
