#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
inline int read() {
  int s = 0, x = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') x = -x;
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * x;
}
const int MAXN = 1e5 + 10;
int n;
int aa[MAXN];
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    aa[i] = read();
  }
  std::sort(aa + 1, aa + 1 + n);
  int upbound = powl(1e18, 1.0 / n);
  long long int ans = 0x7f7f7f7f7f7f7f7f;
  for (int c = 1; c <= upbound; ++c) {
    long long int cost = 0, pow = 1;
    for (int i = 1; i <= n; ++i) {
      cost += std::abs(aa[i] - pow);
      pow *= c;
    }
    ans = std::min(ans, 1ll * cost);
  }
  printf("%lld\n", ans);
  return 0;
}
