#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long a_max = a[n - 1];
  int x = 1;
  long long f1 = 0;
  long long INF = 1e17;
  long long fx = INF;
  if (n <= 2)
    fx = a[0] - 1;
  else {
    for (int i = 0; i < n; i++) fx += (a[i] - 1);
    while (true) {
      int flag = 0;
      long long sum = 0;
      for (int i = 0; i < n; i++) {
        if (pow(x, i) >= INF) flag = 1;
        sum += abs(pow(x, i) - a[i]);
      }
      if (flag == 1 || pow(x, n - 1) > fx + a_max) break;
      fx = min(fx, sum);
      x++;
    }
  }
  cout << fx << endl;
  return 0;
}
