#include <bits/stdc++.h>
using namespace std;
long long int maxm;
bool too_big(long long int v, long long int k) {
  long long int r = 1;
  for (long long int i = 0; i < k; i++) {
    if (r > maxm / v) {
      return 1;
    }
    r *= v;
  }
  return 0;
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  maxm = 0;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (long long int i = 0; i < n; i++) {
    maxm += 5ll * (long long int)abs(a[i] - 1);
  }
  if (n == 1 || n == 2) {
    cout << a[0] - 1 << "\n";
    return;
  }
  long long int ans = 1e18;
  for (long long int r = 1; !too_big(r, n - 1ll); r++) {
    long long int cost = 0;
    long long int val = 1;
    for (long long int i = 0; i < n; i++) {
      cost += abs(a[i] - val);
      val *= r;
    }
    ans = min(ans, cost);
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  solve();
  return 0;
}
