#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
inline int add(int a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
inline int mul(int a, int b) { return (a * 1ll * b) % 1000000007; }
inline int power(int a, int b) {
  int rt = 1;
  while (b > 0) {
    if (b & 1) rt = mul(rt, a);
    a = mul(a, a);
    b >>= 1;
  }
  return rt;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    long long int ar[n];
    for (int i = 0; i < n; i++) cin >> ar[i];
    sort(ar, ar + n);
    long long int big = (long long int)1e15;
    long long int ans = big;
    int j = 1;
    while (1) {
      long long int tempcost = 0, curpow = 1;
      for (int i = 0; i < n; i++) {
        if (curpow >= big) {
          tempcost = -1;
          break;
        }
        tempcost += abs(curpow - ar[i]);
        curpow *= (j);
      }
      if (tempcost == -1) break;
      ans = min(ans, tempcost);
      j++;
    }
    cout << ans << "\n";
  }
  return 0;
}
