#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 1e14;
  sort(a, a + n);
  int t = pow(1e14, 1.0 / n);
  for (int c = 1; c <= t; c++) {
    long long sum = 0, tmp = 1;
    for (int i = 0; i < n; i++) {
      sum += abs(a[i] - tmp);
      tmp *= c;
    }
    ans = min(ans, sum);
  }
  cout << ans;
  return 0;
}
