#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t--) {
    long long int i, n;
    cin >> n;
    long long int a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    long long int c = 1, num, ans = -1, curr = 0;
    while (1) {
      num = 1;
      curr = 0;
      for (i = 0; i < n; i++) {
        if (num > 1e10) {
          cout << ans;
          return 0;
        }
        curr += abs(num - a[i]);
        num *= c;
      }
      if (ans != -1)
        ans = min(ans, curr);
      else
        ans = curr;
      c++;
    }
  }
  return 0;
}
