#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long raw[maxn];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  long long ans = 0;
  if (n >= 40) {
    for (int i = 1; i <= n; i++) {
      long long a;
      cin >> a;
      ans += abs(a - 1ll);
    }
    cout << ans;
    return 0;
  }
  for (int i = 1; i <= n; i++) cin >> raw[i];
  sort(raw + 1, raw + n + 1);
  ans = 1e17;
  for (int d = 1; d <= 400000; d++) {
    int qwq = n;
    int cnt = 0;
    long long tans = 0;
    long long po = 1;
    while (qwq--) {
      if (po > 1e16) break;
      po *= d;
      cnt++;
    }
    if (cnt != n) break;
    po = 1;
    for (int i = 1; i <= n; i++) {
      tans += abs(po - raw[i]);
      po *= d;
    }
    ans = min(ans, tans);
  }
  cout << ans;
  return 0;
}
