#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100005];
int main() {
  {
    cin >> n;
    for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
    sort(a, a + n);
    long long ans = LLONG_MAX;
    for (int c = 1;; c++) {
      long long now = 1;
      long long tot = 0;
      bool ok = 1;
      for (int i = 0; i < n; i++) {
        tot += abs(now - a[i]);
        now = now * c;
        if (now > 1e14) {
          ok = 0;
          break;
        }
      }
      if (!ok) break;
      ans = min(ans, tot);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
