#include <bits/stdc++.h>
using namespace std;
long long n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  vector<long long> a(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort((a).begin(), (a).end());
  long long minn = 1e18;
  for (int i = 0; i < 1e5 + 5; i++) {
    long long tmp = 0;
    for (int j = 0; j < n; j++) {
      tmp += abs(a[j] - (long long)pow(i, j));
      if (tmp >= (6 * 1e17)) break;
    }
    if (tmp <= minn) {
      minn = tmp;
    } else {
      break;
    }
  }
  cout << minn;
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
