#include <bits/stdc++.h>
using namespace std;
void solve() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, i;
  cin >> n;
  long long int arr[n];
  for (i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  long long int big = 1e15;
  long long int ans = big;
  long long int c = 1;
  while (1) {
    long long int value = 0, pw = 1;
    for (i = 0; i < n; i++, pw *= c) {
      if (pw >= (long long int)big) {
        value = -1;
        break;
      }
      value += abs(pw - arr[i]);
    }
    if (value == -1) break;
    ans = min(ans, value);
    c++;
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tests = 1;
  while (tests--) solve();
  return 0;
}
