#include <bits/stdc++.h>
using namespace std;
const int64_t INF = 1e17;
void solve() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (auto &a : vec) cin >> a;
  sort(vec.begin(), vec.end());
  int64_t ans = INF;
  for (int i = 1; i <= 1e9; i++) {
    int64_t temp = 1;
    int64_t cost = 0;
    for (int j = 0; j < N; j++) {
      cost = cost + abs(vec[j] - temp) >= INF ? INF : cost + abs(vec[j] - temp);
      temp *= i;
      if (temp >= INF) temp = INF;
    }
    if (temp == INF) break;
    ans = min(ans, cost);
  }
  cout << ans << "\n";
}
int main() { solve(); }
