#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  {
    long long n;
    cin >> n;
    vector<long long> v(n);
    for (auto &ele : v) cin >> ele;
    long long answer = 1e18L;
    long long total = accumulate(v.begin(), v.end(), 0LL);
    long long end = 1e5 + 5;
    sort(v.begin(), v.end());
    long long diff = total;
    end = exp((18 * log(10)) / n);
    for (long long i = 1; i <= end; i++) {
      bool flag = false;
      long long cnt = 0;
      for (long long p = 0; p < n; p++) {
        long long x = pow(i, p);
        cnt += abs(x - v[p]);
      }
      if (flag) break;
      answer = min(answer, cnt);
    }
    cout << answer;
  }
  return 0;
}
