#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int maxn = 3e5;
int n, a[200010], tree[200010];
inline void add(int ind, int val) {
  while (ind <= 2e5) {
    tree[ind] += val;
    ind += ind & (-ind);
  }
}
inline int query(int ind) {
  int ret = 0;
  while (ind > 0) {
    ret += tree[ind];
    ind -= ind & (-ind);
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) add(a[i], 1);
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[i] == a[i - 1]) continue;
    long long ans1 = 0;
    for (int j = a[i]; j <= 2e5; j += a[i]) {
      ans1 +=
          (long long)j * (query(min((int)2e5, j + a[i] - 1)) - query(j - 1));
    }
    ans = max(ans, ans1);
  }
  cout << ans;
  return 0;
}
