#include <bits/stdc++.h>
using namespace std;
int64_t suum(int64_t a, int64_t b) {
  return (a + b >= (long long)1e17 ? (long long)1e17 : a + b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n;
  vector<int> a(n);
  for (int &x : a) cin >> x;
  sort(a.begin(), a.end());
  int64_t ans = accumulate(a.begin(), a.end(), 0ll) - n;
  for (int i = 1; i < (long long)1e17; i++) {
    int64_t sum = 0, p = 1;
    for (int j = 0; j < n; j++) {
      sum = (sum + abs(a[j] - p) >= (long long)1e17 ? (long long)1e17
                                                    : sum + abs(a[j] - p));
      p = ((long long)1e17 / p > i ? p * i : (long long)1e17);
    }
    if (p == (long long)1e17 || p / i > ans + a[n - 1]) break;
    ans = min(ans, sum);
  }
  cout << ans;
  return 0;
}
