#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MX = 200005;
int N, M, k;
int arr[MX * 2];
long long f[MX * 2];
map<int, int> m;
int main() {
  scanf("%d", &N);
  int mx = 0;
  for (int i = 1; i <= N; i++) {
    int x;
    cin >> x;
    arr[i] = x;
    ++m[arr[i]];
  }
  int i = mx, j = mx;
  long long an = 0;
  for (int i = 1; i <= 250000; i++) {
    map<int, int>::iterator it = m.begin();
    int rem = N;
    long long f = 0;
    while (it != m.end()) {
      if (it->first > i) {
        f += (long long)i * rem;
        break;
      }
      long long a = i % it->first;
      a *= it->second;
      rem -= it->second;
      f += a;
      it++;
    }
    an = max(an, f);
  }
  cout << an;
  return 0;
}
