#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
void solve() {
  long long int n;
  cin >> n;
  long long int a[n];
  long long int hi = 0;
  for (long long int i = 0; i < n; ++i) {
    cin >> a[i];
    hi += a[i];
  }
  sort(a, a + n);
  long long int ans = hi - n;
  if (n > 50) {
    cout << ans;
    return;
  }
  for (long long int i = 1; i < 1e9 + 1; ++i) {
    long long int c = i;
    long long int tmp = 0;
    long long int dig = 0;
    while (c > 0) {
      c = c / 10;
      dig++;
    }
    long long int no = 1;
    c = i;
    bool ex = true;
    for (long long int j = 0; j < n; ++j) {
      tmp += abs(a[j] - no);
      if ((no * c) > 1e14 || (no * c) < 0) {
        ex = false;
        break;
      }
      long long int digi = 0, yo = no;
      while (yo > 0) {
        yo = yo / 10;
        digi++;
      }
      if (digi + dig > 16) {
        ex = false;
        break;
      }
      no = no * c;
    }
    if (ex)
      ans = min(ans, tmp);
    else {
      break;
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
  cerr << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
