#include <bits/stdc++.h>   using namespace std;   int n, a[100000];   long long cost, mn;   int main() {     cin >> n;     for (int i = 0; i < n; ++i) scanf( %d , a + i);     sort(a, a + n);     for (int i = 0; i < n; ++i) mn += a[i] - 1;     if (n > 40) return cout << mn, 0;     for (int i = 2; i <= 1e5; ++i) {       int k = 0;       cost = 0;       for (long long j = 1; j <= 1e10 && k < n; j *= i) {         cost += abs(a[k++] - j);       }       if (k == n) mn = min(mn, cost);     }     cout << mn;   }   