#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
long long a[1000005];
long long qpow(long long x, long long y) {
  long long sum = 1;
  while (y) {
    if (y & 1) sum *= x;
    x = x * x;
    y >>= 1;
  }
  return sum;
}
int main() {
  long long n;
  cin >> n;
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long flag = 0;
  for (long long i = 1; i < n; i++) {
    if (a[i] < a[i - 1]) {
      flag = 1;
      break;
    }
  }
  sort(a, a + n);
  long long ans;
  long long sum = 1e15;
  long long k = (int)(pow(a[n - 1], 1.0 / (n - 1))) + 5;
  for (long long kk = k; kk >= 1; kk--) {
    ans = abs(a[0] - 1);
    for (long long i = 1; i < n; i++) {
      ans += abs(qpow(kk, i) - a[i]);
      if (ans > sum) break;
    }
    sum = min(ans, sum);
  }
  if (sum == 0 && flag) {
    sum++;
  }
  cout << sum << endl;
  return 0;
}
