#include <bits/stdc++.h>
using namespace std;
const long long N = 102020;
const long long B = 1e6 + 11;
const long long inf = 0x3f3f3f3f;
inline long long read() {
  char c = getchar();
  long long x = 0, f = 1;
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
  return x * f;
}
long long n, a[N];
long long ans = 1e18, flag = 0;
inline long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a;
    a = a * a, b >>= 1;
  }
  return res;
}
signed main() {
  n = read();
  for (long long i = 0; i < n; ++i) a[i] = read();
  sort(a, a + n);
  for (long long p = 1; p <= 1e18; p++) {
    if (flag) break;
    long long now = 0;
    for (long long i = 0; i < n; ++i) {
      now += abs(a[i] - (power(p, i)));
      if (now > ans) {
        flag = 1;
        break;
      }
    }
    ans = min(ans, now);
  }
  cout << ans << '\n';
  return 0;
}
