#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
long long a[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long sum = 1e18;
  for (long long i = 1; i; i++) {
    long long res = 1;
    long long g = 0;
    int f = 1;
    for (int j = 0; j < n; j++) {
      if (res > 1e14) {
        f = 0;
        break;
      }
      g += abs(a[j] - res);
      res = res * i;
    }
    if (f == 1) {
      sum = min(sum, g);
    } else {
      break;
    }
  }
  cout << sum << endl;
}
