#include <bits/stdc++.h>
using namespace std;
struct lex_compare {
  bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs) const {
    return lhs.second > rhs.second;
  }
};
void solve() {
  int n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  if (n >= 60) {
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      ans += abs(v[i] - 1ll);
    }
    cout << ans << "\n";
  } else {
    int k = 1;
    while (true) {
      if ((long long)pow(k, n - 1) > v[n - 1]) {
        break;
      }
      k += 1;
    }
    long long ans1 = 0, ans2 = 0;
    for (int i = 0; i < n; i++) {
      ans1 += abs(v[i] - (long long)pow(k, i));
      ans2 += abs(v[i] - (long long)pow(k - 1, i));
    }
    cout << min(ans1, ans2) << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 1;
  for (int i = 0; i < n; i++) {
    solve();
  }
}
