#include <bits/stdc++.h>
#define f first
#define S second
#define pb push_back
#define msk(x , y) ((x >> y) & 1)
#define all(x) x.begin() , x.end()
using namespace std;
typedef long long int ll;
const int N = 2e5 + 7;
const int mod = 1e9 + 7;
const int dx[] = {-1,-1,1,1,2,-2,2,-2};
const int dy[] = {-2,2,2,-2,1,1,-1,-1};
ll n , a[N] , p[N];
ll binpow(ll p , ll q){
if(q == 0) return 1 ;
if(q % 2) return binpow(p , q-1) * p ;
ll b = binpow(p , q / 2);
return b * b;
}
void solve(){
cin >> n ;
ll x = 0 , pos = 1 ;
for(int i = 1 ; i <= n ; i++){
cin >> a[i];
x += a[i] - 1 ;
}
sort(a + 1 , a + n + 1);
x += a[n];
for(ll i = 2 ; i <= ; i++){
ll p = binpow(i , n - 1);
if(p <= x) pos = p ;
else break ;
}
ll ans = x;
for(int i = 2 ; i <= pos ; i++){
ll pw = 1 , res = 0 ;
for(int j = 1 ; j <= n ;j++){
res += abs(pw - a[j]);
pw *= i ;
}
ans = min(ans , res);
}
cout << ans << "\n";
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int test=1;
// cin >> test ;
for(int i=1;i<=test;i++){
// cout << "Case " << i << ": ";
solve();
}
}
Compilation message
climbers.cpp: In function 'void solve()':
climbers.cpp:32:25: error: expected primary-expression before ';' token
32 | for(ll i = 2 ; i <= ; i++){
| ^