#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T maxer(T &a, T b) {
  a = max(a, b);
}
template <typename T>
inline T miner(T &a, T b) {
  a = min(a, b);
}
void inline iOS() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inline fin() { freopen("in", "r", stdin); }
void inline fout() { freopen("out", "w", stdout); }
const int inf = ~0u / 10;
const long long linf = ~0ull / 20;
const int maxn = 1e6 + 20;
long long a[maxn], s[maxn];
int maxx = 200000;
int main() {
  iOS();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x]++;
  }
  for (int i = maxx; i >= 1; i--) s[i] = s[i + 1] + a[i];
  long long ans = 0;
  for (int i = 1; i <= maxx; i++) {
    if (!a[i]) continue;
    long long cur = 0;
    for (long long j = i; j <= maxx; j += i) cur += (s[j] - s[j + i]) * j;
    maxer(ans, cur);
  }
  cout << ans;
  return 0;
}
