#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long mod = 998244353;
const double eps = 1e-9;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
inline long long read() {
  long long ret = 0, sgn = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') sgn = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    ret = ret * 10 + ch - '0';
    ch = getchar();
  }
  return ret * sgn;
}
inline void Out(long long a) {
  if (a > 9) Out(a / 10);
  putchar(a % 10 + '0');
}
long long qpow(long long m, long long k, long long mod) {
  long long res = 1 % mod, t = m % mod;
  while (k) {
    if (k & 1) res = res * t % mod;
    t = t * t % mod;
    k >>= 1;
  }
  return res;
}
long long __gcd(long long a, long long b) {
  return b == 0 ? a : __gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / __gcd(a, b) * b; }
long long inv(long long x, long long mod) {
  return qpow(x, mod - 2, mod) % mod;
}
const long long N = 5e5 + 7;
long long n, m;
long long a[N];
long long cnt[30];
signed main() {
  long long t = 1, cas = 1;
  while (t--) {
    cin >> n;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a, a + n);
    long long maxx = 1e16;
    long long minn = 0;
    long long tmp = 1;
    for (long long i = 0; i < 10000000 / n; i++) {
      tmp = 1;
      long long tt = 0;
      for (long long j = 0; j < n; j++) {
        tt += abs(a[j] - tmp);
        tmp *= (i + 1);
        if (tt > maxx) break;
      }
      if (tt < maxx) {
        maxx = tt;
        minn = tt;
      }
    }
    cout << maxx << endl;
  }
}
