#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  ll arr[n];
  for (int i = 0; i < n; ++i) cin >> arr[i];
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += arr[i] - 1;
  }
  sort(arr, arr + n);
  int val = 1;
  while (1) {
    ll ini = 1, i = 1, cnt = 0;
    cnt += arr[0] - 1;
    for (; i < n; ++i) {
      ini *= val;
      if (ini > 1e10) break;
      cnt += abs(ini - arr[i]);
    }
    if (i != n) {
      break;
    }
    ans = min(ans, cnt);
    val++;
  }
  cout << ans << '\n';
  ;
  return 0;
}
