#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T = 1;
  while (T--) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    long long ans = (long long)1e17;
    for (int c = 1; c <= 100000; c++) {
      if (pow(c, n - 1) > 1e10) break;
      long long a1 = 0, c2 = 1, f = 1;
      for (int i = 0; i < n; i++) {
        a1 += abs(a[i] - c2);
        c2 *= c;
        if (c2 < 0) {
          f = 0;
          break;
        }
      }
      if (f == 0) break;
      ans = min(ans, a1);
    }
    cout << ans;
  }
  return 0;
}
