#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 9;
long long n, a[N];
const long long oo = 1e18;
void Input() {
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
}
void Solve() {
  long long ans = 1e18;
  for (long long c = 1; c <= 1000000; c++) {
    long long now = 1;
    long long tmp = 0;
    for (long long i = 1; i <= n; i++) {
      tmp += abs(a[i] - now);
      if (now > oo / c) break;
      now *= c;
    }
    ans = min(ans, tmp);
  }
  cout << ans;
}
int main() {
  if (fopen("trash.inp", "r")) freopen("trash.inp", "r", stdin);
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  Input();
  Solve();
}
