#include <bits/stdc++.h>
using namespace std;
long long a[100005];
long long req = 1e18;
long long steps(long long n) {
  long long c = 1;
  if (n == 1) return 1e6;
  while (req > 1) {
    req /= n;
    c++;
  }
  req = 1e18;
  return c;
}
long long pow_exp(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n % 2) res = (res * a);
    a = (a * a);
    n /= 2ll;
  }
  return res;
}
int main() {
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    long long ans = 0;
    for (long long i = 0; i < n; i++) cin >> a[i], ans += (a[i] - 1ll);
    sort(a, a + n);
    if (n == 1) {
      cout << a[0] - 1ll << endl;
      continue;
    }
    long long st = 2;
    while (steps(st) >= n - 1) {
      long long sol = 0;
      for (long long i = 0; i < n; i++) {
        long long u = pow_exp(st, i);
        sol += abs(u - a[i]);
      }
      ans = min(ans, sol);
      if (pow_exp(st, n - 1) > a[n - 1]) break;
      st++;
    }
    cout << ans << endl;
  }
}
