#include <bits/stdc++.h>
using namespace std;
const int nmax = 100005;
int v[nmax];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
  }
  sort(v + 1, v + n + 1);
  long long ans = (1LL << 60);
  int last;
  for (int i = 1; i <= (int)sqrt(v[n]) + 1; ++i) {
    long long contor = 0;
    bool ok = true;
    for (int j = 1; j <= n; ++j) {
      contor += abs(v[j] - pow(i, (j - 1)));
      if (contor > ans) {
        ok = false;
        break;
      }
    }
    if (ok && contor < ans) {
      ans = contor;
    }
    if (ok == false) {
      break;
    }
  }
  cout << ans << "\n";
}
