#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int TOO_LONG_SEQ = 64;
vector<ll> seq;
int n;
void input() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    seq.push_back(a);
  }
}
ll compute_baseline() {
  ll res = 0;
  for (ll a : seq) {
    res += a;
  }
  return res - seq.size();
}
bool lin_pow_less(ll a, ll p, ll thres) {
  ll res = 1;
  while (p-- && res < thres) {
    res *= a;
  }
  return res < thres;
}
ll compute_result() {
  ll baseline = compute_baseline();
  if (n >= TOO_LONG_SEQ || n == 1) {
    return baseline;
  }
  sort(seq.begin(), seq.end());
  if (n == 2) {
    return min(baseline, seq[0] - 1);
  }
  ll c = 2, cur_res = baseline;
  while (lin_pow_less(c, n - 1, cur_res + seq.back())) {
    ll cand_res = 0;
    ll cur_item = 1;
    for (int i = 0; i < n && cand_res < cur_res; i++) {
      cand_res += abs(seq[i] - cur_item);
      cur_item *= c;
    }
    cur_res = min(cur_res, cand_res);
    c++;
  }
  return cur_res;
}
int main() {
  ios_base::sync_with_stdio(0);
  input();
  cout << compute_result() << "\n";
  return 0;
}
