#include <bits/stdc++.h>
using namespace std;
long long fastpow(long long a, long long n) {
  if (n == 0) {
    return 1;
  } else if (n % 2 == 1) {
    return a * fastpow(a, n - 1);
  } else {
    long long tmp = fastpow(a, n / 2);
    return tmp * tmp;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  long long ans = 1e18 + 7, sum, tmp;
  bool bl;
  for (long long curr = 1;; ++curr) {
    sum = 0;
    bl = 0;
    for (int i = 0; i < n; ++i) {
      tmp = fastpow(curr, i);
      if (tmp > 1e16) {
        bl = 1;
        break;
      }
      sum += abs(v[i] - tmp);
    }
    if (bl) {
      break;
    }
    if (sum > ans) {
      break;
    } else {
      ans = sum;
    }
  }
  cout << ans;
}
