#include <bits/stdc++.h>
using namespace std;
using lli = long long;
int main() {
  int n;
  cin >> n;
  vector<lli> A(n);
  for (auto& Ai : A) cin >> Ai;
  sort(A.begin(), A.end());
  lli ans = 9876543212345678;
  lli lim = 1000000000000000;
  for (lli v = 1; v <= 100000; v++) {
    int finished = 0;
    lli sum = 0;
    lli vi = 1;
    for (int i = 0; i < n; i++) {
      sum += abs(A[i] - vi);
      vi *= v;
      if (vi > lim) {
        finished = 1;
        break;
      }
    }
    if (ans > sum) {
      ans = sum;
    }
    if (finished) break;
  }
  cout << ans << '\n';
}
