#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void debug() { cerr << "]\n"; }
template <class H, class... T>
void debug(H h, T... t) {
  cerr << h;
  if (sizeof...(t)) {
    cerr << ", ";
  }
  debug(t...);
}
int n;
vector<int> a;
ll mn = 1e18;
ll bpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1LL) {
      res = (res * a);
    }
    a = a * a;
    b /= 2;
  }
  return res;
}
void solve() {
  cin >> n;
  a = vector<int>(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort((a).begin(), (a).end());
  ll c = 1;
  if (n < 63)
    while (bpow(c, 1LL * (n - 1)) < 1LL * a.back()) {
      c++;
    }
  for (int i = 1; i < c + 1; i++) {
    ll cnt = 0;
    ll cost = 0;
    for (int j = 0; j < n; j++) {
      cnt += abs(bpow(i, j) - a[j]);
    }
    mn = min(mn, cnt);
  }
  cout << mn << "\n";
  mn = 1e18;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int _;
  _ = 1;
  for (int i = 1; i <= _; i++) {
    solve();
  }
  return 0;
}
