#include <bits/stdc++.h>
using namespace std;
int main() {
  int num = pow(10, 5);
  int arr[num + 1];
  arr[1] = INT_MAX;
  for (int i = 2; i < num + 1; i++) {
    long long int temp = 0;
    int j = 0;
    while (true) {
      j++;
      if (powl(i, j) > powl(10, 14)) {
        break;
      }
    }
    arr[i] = j;
  }
  int n;
  cin >> n;
  int targ[n];
  for (int i = 0; i < n; i++) cin >> targ[i];
  sort(targ, targ + n);
  long long int mn = LONG_LONG_MAX;
  for (int i = 1; i < num + 1; i++) {
    if (arr[i] < n - 1) break;
    long long int diff = 0;
    for (int j = 0; j < n; j++) {
      diff += abs(powl(i, j) - targ[j]);
    }
    mn = min(diff, mn);
  }
  cout << mn;
  return 0;
}
