#include <bits/stdc++.h>
using namespace std;
long long a[100100];
signed main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  sort(a, a + n);
  long long ret = (long long)1e18;
  for (long long i = 1; i <= 100000; i++) {
    vector<long long> t;
    long long ans = 1;
    for (long long j = 0; j < n; j++) {
      t.push_back(ans);
      ans *= i;
      if (ans > (long long)1e18) {
        break;
      }
    }
    if ((long long)t.size() < n) {
      break;
    }
    long long sum = 0;
    for (long long j = 0; j < n; j++) {
      sum += (long long)abs(a[j] - t[j]);
      if (sum > ret) {
        break;
      }
    }
    if (sum < 0) {
      continue;
    }
    ret = min(ret, sum);
  }
  cout << ret << "\n";
  return 0;
}
