#include <bits/stdc++.h>
using namespace std;
int modulo = 1e9 + 7;
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
int main() {
  long long n;
  cin >> n;
  long long MAX = 10000000000000000;
  long long arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  long long c = 1;
  while (pow(c, n - 1) < arr[n - 1]) c++;
  long long ans = 10000000000000000;
  for (int i = 2; i <= c; i++) {
    long long currAns = 0;
    for (int j = 0; j < n; j++) {
      long long p = pow(i, j);
      if (currAns + abs(p - arr[j]) > MAX) break;
      currAns += abs(p - arr[j]);
    }
    ans = min(ans, currAns);
  }
  long long sm = 0;
  for (int i = 0; i < n; i++) sm += (arr[i] - 1);
  ans = min(sm, ans);
  cout << ans << "\n";
}
