#include <bits/stdc++.h>
using namespace std;
int a[(10010)], n;
const long long INF = 1ll << 62;
long long divs(int x, int y) {
  long long tot = 0, p, q;
  for (int i = 1; i <= n; i++) {
    if (a[i] % y == 0) {
      p = 0;
      q = a[i] - a[i] / y * x;
    } else {
      p = (1ll * a[i] / y + 1) * y - a[i];
      q = a[i] - (1ll * a[i] / y + 1) * x;
    }
    if (q >= 0) {
      tot += p + q;
    } else {
      return INF;
    }
  }
  return tot;
}
int main() {
  while (scanf("%d", &n) == 1 && n > 0 && n <= 500) {
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", a + i);
      ans += a[i];
    }
    sort(a + 1, a + n + 1);
    int ub = sqrt(a[1]);
    ub += 1;
    int flag = 1;
    for (int k = 1; k <= ub; k++) {
      int c = a[1] / k;
      if (c > 0) {
        long long tmp = divs(c, c + 1);
        if (tmp != INF) {
          ans = tmp;
          flag = 0;
          break;
        }
      }
      if (c > 1 && a[1] % k == 0) {
        long long tmp = divs(c - 1, c);
        if (tmp != INF) {
          ans = tmp;
          flag = 0;
          break;
        }
      }
    }
    for (int k = ub; k && flag; k--) {
      long long tmp = divs(k, k + 1);
      if (tmp != INF) {
        ans = tmp;
        flag = 0;
      }
    }
    printf("%I64d\n", ans);
  }
}
