#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
const long double pi = 3.14159265358979323846;
const char nl = '\n';
const long long inf = 1e15;
long long mul(long long x, long long y) { return (1ll * (x) * (y)); }
long long power(long long x, long long y) {
  long long z = 1;
  while (y > 0) {
    if (y % 2) z = mul(z, x);
    x = mul(x, x);
    y /= 2;
  }
  return z;
}
void solve() {
  int n;
  cin >> n;
  vector<long long> v(n);
  for (auto &x : v) {
    cin >> x;
  };
  sort(((v).begin()), ((v).end()));
  long long i = 1;
  long long ans = inf;
  while (true) {
    long long c = 0;
    long long p = 1;
    bool f = true;
    for (int j = 0; j < n; j++) {
      c += abs(v[j] - p);
      p *= i;
      if (p >= 100000000000000) {
        f = false;
        break;
      }
    }
    if (f) {
      ans = min(ans, c);
    } else {
      break;
    }
    i++;
  }
  cout << ans << '\n';
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
