#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
T maxn(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T minn(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
void solve() {
  long long int n;
  cin >> n;
  long long int a[n];
  for (long long int(i) = 0; (i) < (n); (i)++) cin >> a[i];
  sort(a, a + n);
  long long int mx =
      pow(10, (((long long int)(min(9LL + n, 15LL)) * 1.0) / (n - 1)));
  long long int ans = LLONG_MAX;
  for (long long int(i) = 1; (i) < (mx + 1); (i)++) {
    long long int tmp = 0, val = 1;
    for (long long int(j) = 0; (j) < (n); (j)++) {
      tmp += abs(a[j] - val);
      val *= i;
    }
    minn(ans, tmp);
  }
  cout << ans;
}
signed main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int testcase = 1;
  while (testcase--) solve();
  return 0;
}
