#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<long long> a;
  for (int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  long long ans = 7e18;
  long long ro = pow((double)1e10, (double)1 / (n - 1));
  if (ro == 0) ro = 1;
  for (long long i = 1; i <= ro; ++i) {
    long long pw = 1;
    long long curr = 0;
    for (int j = 0; j < n; ++j, pw *= i) {
      curr += abs(pw - a[j]);
    }
    ans = min(ans, curr);
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  solve();
  return 0;
}
