#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  cin >> n;
  vector<long long> a(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += abs(a[i] - 1);
  }
  if (n >= 48) {
    cout << ans << endl;
  } else {
    long long c = 1;
    for (long long i = 2;; i++) {
      long long curr = 1;
      long long mul = 1;
      long long j;
      for (j = 1; j < n; j++) {
        mul *= i;
        curr += (mul);
        if (curr > 2 * sum) break;
      }
      if (j != n || curr > 2 * sum) {
        break;
      } else {
        long long aa = abs(1 - a[0]);
        long long mm = 1;
        for (long long t = 1; t < n; t++) {
          mm *= i;
          aa += abs(mm - a[t]);
        }
        ans = min(ans, aa);
        c = i;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
