#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 3e5, M = N;
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);
vector<int> g[N];
void solve() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long big = (long long)1e15;
  long long ans = big;
  long long c = 1;
  int k = 0;
  while (1) {
    long long val = 0, pw = 1;
    for (int i = 0; i < n; i++, pw *= c) {
      if (pw >= (long long)(big)) {
        val = -1;
        break;
      }
      val += abs(pw - a[i]);
    }
    if (val == -1) break;
    ans = min(ans, val);
    c++;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  clock_t z = clock();
  int t = 1;
  while (t--) {
    solve();
  }
  fprintf(stderr, "Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC),
      fflush(stderr);
  return 0;
}
