#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 7;
int main() {
  int n, a[M];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int check[M] = {0};
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (check[a[i]] != 0) continue;
    check[a[i]] = 1;
    int bef = i;
    long long t = 0;
    for (int j = 2 * a[i]; j <= a[i] * (a[n - 1] / a[i] + 1); j += a[i]) {
      if (j < a[n - 1]) check[j] = 1;
      int now = lower_bound(a + i, a + n, j) - a;
      t += (long long)(j - a[i]) * (now - bef);
      bef = now;
    }
    ans = max(ans, t);
  }
  cout << ans;
}
