#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long d =
      pow((long double)a[n - 1], (long double)((long double)1 / (n - 1)));
  long long e = pow((long double)1E11, (long double)((long double)1 / (n - 1)));
  long long sum = 0, sum1 = 0;
  for (int i = 0; i < n; i++) {
    if (pow(d, i) > a[i])
      sum += (long long)pow(d, i) - a[i];
    else
      sum += a[i] - (long long)pow(d, i);
    if (d + 1 <= e) {
      if (pow(d + 1, i) > a[i])
        sum1 += (long long)pow(d + 1, i) - a[i];
      else
        sum1 += a[i] - (long long)pow(d + 1, i);
    }
  }
  if (d + 1 <= e)
    cout << min(sum, sum1) << endl;
  else
    cout << sum << endl;
  return 0;
}
