#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int n;
int cnt[maxn];
int pref[maxn];
int maxv;
int main(void) {
  scanf("%d", &n);
  long long prev = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
    maxv = max(maxv, x);
  }
  for (int i = 1; i <= maxv; i++) pref[i] = pref[i - 1] + cnt[i];
  long long sol = 0;
  for (int i = 1; i <= maxv; i++) {
    if (cnt[i] == 0) continue;
    long long curr = 0;
    for (int j = 1; i * j <= maxv; j++) {
      int lo = i * j;
      int hi = i * (j + 1) - 1;
      int preff;
      if (hi > maxv)
        preff = pref[maxv];
      else
        preff = pref[hi];
      curr += (long long)(i * j) * (preff - pref[lo - 1]);
    }
    sol = max(sol, curr);
  }
  cout << sol << endl;
  return 0;
}
