#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL maxn = 1e15 + 10;
const int M_MAX = 800000 + 10;
const int mod = 10007;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
void solve() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr.begin(), arr.end());
  LL mx = pow(maxn, (double)1 / n) + 1;
  LL ans = -1;
  for (LL i = 1; i <= mx; i++) {
    LL sum = 0;
    LL t = 1;
    int flag = 1;
    for (int j = 0; j < n; j++) {
      sum += abs(arr[j] - t);
      t *= i;
      if (sum > maxn) {
        flag = 0;
        break;
      }
    }
    if (!flag) continue;
    if (ans == -1) ans = sum;
    ans = min(ans, sum);
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
