#include <bits/stdc++.h>
using namespace std;
long long n, a[666666], b[666666];
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]), b[i] = a[i];
  sort(b + 1, b + 1 + n);
  long long ans = 999999999999999;
  for (long long c = 1;; c++) {
    long long s = 1, sum = 0, f = 1;
    for (long long j = 1; j <= n; j++) {
      sum += abs(b[j] - s);
      if (sum > ans) {
        f = 0;
        break;
      }
      s = s * c;
    }
    if (f)
      ans = min(ans, sum);
    else
      break;
  }
  cout << ans;
  return 0;
}
