#include <bits/stdc++.h>
using namespace std;
long long N = 1e10;
int main() {
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n + 1];
    long long mn = 1e18;
    for (long long i = 1; i <= n; i++) {
      cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    for (long long i = 1; i <= 100000; i++) {
      long long ans = i;
      long long sum = 0;
      for (long long j = 1; j <= n; j++) {
        sum += abs(a[j] - pow(ans, (j - 1)));
        if (sum > mn) break;
      }
      mn = min(mn, sum);
    }
    cout << mn << endl;
  }
}
