#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, t;
int i, j, k;
long long a[N];
int main() {
  while (cin >> (n)) {
    for (i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    long long ans = 1e18;
    for (int q = 1; q <= 1e5; q++) {
      long long sum = 0ll;
      long long now = 1ll;
      bool flag = 1;
      for (i = 0; i < n; i++) {
        if (now > 1e14) {
          flag = 0;
          break;
        }
        sum += abs(a[i] - now);
        now *= q;
      }
      if (flag)
        ans = min(ans, sum);
      else
        break;
    }
    cout << ans;
  }
  return 0;
}
