#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int64_t func(int64_t c) {
  int64_t cost = 0, pc = 1;
  for (int ai : a) {
    long long diff = ai - pc;
    cost += abs(diff);
    if (pc > LLONG_MAX / c) return LLONG_MAX;
    pc *= c;
  }
  return cost;
}
int main(void) {
  int n;
  cin >> n;
  int64_t ans = 0;
  a.resize(n);
  for (int& ai : a) {
    cin >> ai;
    ans += abs(ai - 1);
  }
  sort(a.begin(), a.end());
  int64_t l = 2, r = 1e9, maxc = 0;
  while (l <= r) {
    int64_t mid = l + (r - l) / 2;
    int64_t c = func(mid);
    if (c > ans) {
      maxc = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  l = 2;
  r = 1e9;
  while (r - l > 3) {
    int64_t m1 = l + (r - l) / 3;
    int64_t m2 = r - (r - l) / 3;
    int64_t c1 = func(m1);
    int64_t c2 = func(m2);
    ans = min(ans, c1);
    ans = min(ans, c2);
    if (c1 > c2)
      l = m1;
    else
      r = m2;
  }
  for (int64_t i = l; i <= r; i++) ans = min(ans, func(i));
  cout << ans << '\n';
}
