#include <bits/stdc++.h>
using namespace std;
#include<map>
#define REP(i,a,b) for(int i=a;i<b;i++)
#define NREP(i,a,b) for(int i=a;i>=b;i--)
#define clr(a) memset(a,0,sizeof a)
#define CLR(a,t) memset(a,t,sizeof a)
#define help ios::sync_with_stdio(0)
#define SORTV(a,n) sort(a.begin(),a.begin()+n)
#define SORTA(a,n) sort(a,a+n)
#define f first
#define ii second
#define mp make_pair
#define pb push_back
typedef long long int ll;
typedef long double ld;
#define vip vector<pair<ll,ll>>
#define vv vector<vector<ll>>
#define vi vector<ll>
#define FORS(it,m) for(set<int>::iterator it=m.begin();it!=m.end();it++)
#define FORM(it,m) for(map<ll,ll>::iterator it=m.begin();it!=m.end();it++)
#define FORV(it,m) for(vector<ll>::iterator it=m.begin();it!=m.end();it++)
#define FORL(it,l) for(list<int> :: iterator it=l.begin();it!=l.end();it++)
#define MAX6 1000000
#define MAX5 100000
#define MAX4 10000
#define ipair pair<ll,ll>
#define deb(x) cout<<#x<<"="<<x<<endl
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define minHeap priority_queue<ipair,vector<ipair>,greater<ipair>>
#define maxHeap priority_queue<ipair>
#define iminHeap priority_queue<ll,vector<ll>,greater<ll>>
#define imaxHeap priority_queue<ll>
#define iMap map<ll,ll>
#define iuMap unordered_map<ll, ll>
#define piMap map<pair<ll,ll>,ll>

#define sz(a) a.size()
#define tc(t) ll t; cin>>t; while(t--)
#define debArr(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" ";  cout<<endl;
#define si cout<<"YES"<<endl;
#define nada cout<<"NO"<<endl;
ll upperBound(ll a[],ll n,ll val) {return upper_bound(a,a+n,val)-a;}
ll lowerBound(ll a[],ll n,ll val) {return lower_bound(a,a+n,val)-a;}
bool persqr(int a) { return (int(sqrt(a))*int(sqrt(a))==a)?1:0; }
ll gcd(ll a,ll b) { return (a?gcd(b%a,a):b);}
bool powerOf2(int a)   {   return !(a&(a-1));}
ll abs(ll n1,ll n2){    return n1>n2?n1-n2:n2-n1;}
ll highestPowerof2(ll n) { return pow(2,(ll)log2(n)); }

ll n,a[MAX6],sum,ans;

ll power(ll xx, ll yy) //DO NOT REMOVE IT!!
{
    if (yy == 0)    return 1;
    ll pp=power(xx, yy / 2);
    if (yy % 2 == 0) return (pp * pp);
    return ((xx * pp) * pp);
}

ll func(ll c){
    ll cnt=0;
    REP(i,0,n){
        cnt+=labs(a[i]-power(c,i));
    }
    return cnt;
}

int main(){
    help;
    ans=LLONG_MAX;
    cin>>n;
    REP(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    SORTA(a,n);
    long double pq = log10(a[n-1]+0.0)/(n-1.0);
    ll p = floor(pow(10.000,pq));
    ans=func(p);
    // cout<<p<<endl;
    if(p>1) ans=min(ans,func(p-1));
    ans=min(ans,func(p+1));
    cout<<ans<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log(c)>50)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log2(c)>44)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log2(c)>50)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log(c)>20)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log(c)>28)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log(c)>30)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log2(c)>30)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log2(c)>31)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log(c)>22)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log(c)>29)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log2(c)>40)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log2(c)>36)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log2(c)>32)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble;
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll as=infl;
    ll c=1;
    while(c){
        ll x=c;
        ll cnt=abs(a[0]-1);
        for(int i=1;i<n;i++){
            cnt+=abs(a[i]-x);
            x*=c;
        }
        as=min(as,cnt);
        c++;
        if((n-1)*log2(c)>35=2)
            break;
    }
    cout<<as<<nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e15 + 1;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];}
    sort(a, a + n);
    long long t = 0;
    while((pow(t, n)*1ll) < sum) t++;
    for(long long i = 1; i <= 1000000; i++){
        //cout<<i<<endl;
        long long s = 0;
        for(long long j = 0; j < n; j++){
            s = s + abs(a[j] - pow(i,j)*1ll);
            //cout<<s<<" ";
        }
        //cout<<endl;
        ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
long long power(long long a, long long b){
    long long s = 1;
    for(long long i = 0; i < b; i++) s = s * a;
    return s;
}
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e15 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    bool fl = true;
    for(int i = 0; i < n - 1; i++) if(a[i] > a[i + 1]){
        fl = false;
        break;
    }
    sort(a, a + n);
    long long t = 1;
    while(power(t, n - 1) < (ma + sum - n)) t++;
    for(long long i = 1; i <= t; i++){
        long long s = 0;
        for(long long j = 0; j < n; j++){
            long long p = power(i, j);
            s = s + max(a[j] - p, p - a[j]);
            //cout<<s<<" ";
        }
        //cout<<endl;
        if(ans >= s) ans = s;
        else {break;}
        //ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    //if(!ans && !fl) ans = 1;
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e15 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    sort(a, a + n);
//    cout<<sum<<" "<<ma<<"\n";
//    long long t = log2(sum)/log2(n - 1);
    long long t;
    while((pow(t, n-1)*1ll) <= sum) {t++;}
    //cout<<t<<endl;
    for(long long i = 1; i*i <= sum*2; i++){
        //cout<<i<<endl;
        long long s = 0;
        for(long long j = 0; j < n; j++){
            s = s + abs(a[j] - pow(i,j)*1ll);
            //cout<<s<<" ";
        }
        //cout<<endl;
        if(ans > s) ans = s;
        else break;
        //ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
long long power(long long a, long long b){
    long long s = 1;
    for(long long i = 0; i < b; i++) s = s * a;
    return s;
}
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e18 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    bool fl = true;
    for(int i = 0; i < n - 1; i++) if(a[i] > a[i + 1]){
        fl = false;
        break;
    }
    sort(a, a + n);
    long long t = 1;
    while(power(t, n - 1) <= ma) t++;
    for(long long i = 1; i <= t + 1; i++){
        long long s = 0;
        for(long long j = 0; j < n; j++){
            long long p = power(i, j);
            s = s + max(a[j] - p, p - a[j]);
            //cout<<s<<" ";
        }
        //cout<<endl;
        if(ans > s) ans = s;
        else {break;}
        //ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    //if(!ans && !fl) ans = 1;
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 2e5 + 1;
long long a[MX], l[MX], r[MX];
long long power(long long a, long long n){
    long long s = 1;
    for(long long i = 0; i < n; i++) s = s*a;
    return s;
}
int main(){
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i];
    long long sum = 0, mx = 0;
    sort(a, a+n);
    for(int i = 0; i < n; i++){
        sum += a[i] - 1ll;
        mx = max(mx, a[i]);
    }
    long long mi = 1e18 + 1ll;
    long long d = 1;
    while(power(d, n - 1ll) <= (mx + sum)) d++;
    for(long long i = 1; i <= d; i++){
        long long ans = 0;
        for(long long j = 0 ; j < n; j++) ans += abs(a[j] - power(i, j));
        mi = min(ans, mi);
    }
    cout<<mi;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

const int64_t INF = 1e17;
inline int64_t mul(int64_t a, int64_t b)
{
	return (INF / a > b ? a * b : INF);
}

inline int64_t add(int64_t a, int64_t b)
{
	return (a + b >= INF ? INF : a + b);
}

int main()
{
	int n;
	cin >> n;

	vector<int> a(n);
	for (int &x : a) cin >> x;
	sort(a.begin(), a.end());

	if (n <= 2) {
		cout << a[0] - 1 << endl;
	} else {
		int64_t ans = accumulate(a.begin(), a.end(), 0ll) - n;

		for (int x = 1; ; ++x) {
			int64_t curPow = 1, curCost = 0;
			for (int i = 0; i < n; ++i) {
				curCost = add(curCost, abs(a[i] - curPow));
				curPow = mul(curPow, x);
			}

			if (curPow == INF || curPow / x > ans + a[n - 1]) break;
			ans = min(ans, curCost);
//			if(ans > curCost) ans = curCost;
//			else {cout<<x-1;break;}
		}

		cout << ans << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
long long power(long long a, long long b){
    long long s = 1;
    for(long long i = 0; i < b; i++) s = s * a;
    return s;
}
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e18 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    bool fl = true;
    for(int i = 0; i < n - 1; i++) if(a[i] > a[i + 1]){
        fl = false;
        break;
    }
    sort(a, a + n);
    long long t = sqrt(sum);
    for(long long i = 1; i <= t + 1; i++){
        long long s = 0;
        for(long long j = 0; j < n; j++){
            long long p = power(i, j);
            s = s + max(a[j] - p, p - a[j]);
            //cout<<s<<" ";
        }
        //cout<<endl;
        if(ans > s) ans = s;
        else {break;}
        //ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    //if(!ans && !fl) ans = 1;
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 2e5 + 1;
long long a[MX], l[MX], r[MX];
long long power(long long a, long long n){
    long long s = 1;
    for(int i = 0; i < n; i++) s = s*a;
    return s;
}
int main(){
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i];
    long long sum = 0, mx = 0;
    sort(a, a+n);
    for(int i = 0; i < n; i++){
        sum += a[i] - 1;
        mx = max(mx, a[i]);
    }
    long long mi = 1e18 + 1;
    long long d = 0;
    while(power(d, n - 1) < mx + sum) d++;
    for(long long i = 1; i <= d; i++){
        long long ans = 0;
        for(int j = 0 ; j < n; j++) ans += abs(a[j] - power(i, j));
        mi = min(ans, mi);
    }
    cout<<mi;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e15 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    sort(a, a + n);
    long long t = 0;
    //while((pow(t, n)*1ll) < sum) t++;
    for(long long i = 1; i*i <= sum; i++){
        //cout<<i<<endl;
        long long s = 0;
        for(long long j = 0; j < n; j++){
            s = s + abs(a[j] - pow(i,j)*1ll);
            //cout<<s<<" ";
        }
        //cout<<endl;
        ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
long long power(long long a, long long b){
    long long s = 1;
    for(long long i = 0; i < b; i++) s = s * a;
    return s;
}
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 0, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    bool fl = true;
    for(int i = 0; i < n - 1; i++) if(a[i] > a[i + 1]){
        fl = false;
        break;
    }
    sort(a, a + n);
    long long t = 1;
    while(power(t, n - 1) <= ma) t++;
    for(int i = 0; i < n; i++){
        long long p = power(1, i);
        ans += max(a[i] - p, p - a[i]);
    }
    for(long long i = 2; i <= t + 1; i++){
        long long s = 0;
        for(long long j = 0; j < n; j++){
            long long p = power(i, j);
            s = s + max(a[j] - p, p - a[j]);
            //cout<<s<<" ";
        }
        //cout<<endl;
        if(ans >= s) ans = s;
        else {break;}
        //ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    //if(!ans && !fl) ans = 1;
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
long long power(long long a, long long b){
    long long s = 1;
    for(long long i = 0; i < b; i++) s = s * a;
    return s;
}
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e18 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    bool fl = true;
    for(int i = 0; i < n - 1; i++) if(a[i] > a[i + 1]){
        fl = false;
        break;
    }
    sort(a, a + n);
    long long t = sqrt(ma);
    for(long long i = 1; i <= t+1; i++){
        long long s = 0;
        for(long long j = 0; j < n; j++){
            long long p = power(i, j);
            s = s + max(a[j] - p, p - a[j]);
            //cout<<s<<" ";
        }
        //cout<<endl;
        if(ans > s) ans = s;
        else {break;}
        //ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    //if(!ans && !fl) ans = 1;
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e15 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    sort(a, a + n);
    long long t = 1ll*(log2(sum)/log2(n - 1));
    //while((pow(t, n-1)*1ll) <= sum) {cout<<t<<endl;t++;}
    //cout<<t<<endl;
    for(long long i = 1; i <= t; i++){
        //cout<<i<<endl;
        long long s = 0;
        for(long long j = 0; j < n; j++){
            s = s + abs(a[j] - pow(i,j)*1ll);
            //cout<<s<<" ";
        }
        //cout<<endl;
        ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
long long power(long long a, long long b){
    long long s = 1;
    for(long long i = 0; i < b; i++) s = s * a;
    return s;
}
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 0, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    bool fl = true;
    for(int i = 0; i < n - 1; i++) if(a[i] > a[i + 1]){
        fl = false;
        break;
    }
    sort(a, a + n);
    long long t = 1;
    //while(power(t, n - 1) <= ma) t++;
    for(int i = 0; i < ma; i++){
        long long p = power(1, i);
        ans += max(a[i] - p, p - a[i]);
    }
    for(long long i = 2; i <= t + 1; i++){
        long long s = 0;
        for(long long j = 0; j < n; j++){
            long long p = power(i, j);
            s = s + max(a[j] - p, p - a[j]);
            //cout<<s<<" ";
        }
        //cout<<endl;
        if(ans >= s) ans = s;
        else {break;}
        //ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    //if(!ans && !fl) ans = 1;
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e15 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    sort(a, a + n);
    long long t = 0;
    while((pow(t, n-1)*1ll) <= ma) t++;
    for(long long i = 1; i <= t; i++){
        //cout<<i<<endl;
        long long s = 0;
        for(long long j = 0; j < n; j++){
            s = s + abs(a[j] - pow(i,j)*1ll);
            //cout<<s<<" ";
        }
        //cout<<endl;
        ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e15 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    bool fl = true;
    for(int i = 0; i < n - 1; i++) if(a[i] > a[i + 1]){
        fl = false;
        break;
    }
    sort(a, a + n);
//    cout<<sum<<" "<<ma<<"\n";
//    long long t = log2(sum)/log2(n - 1);
//    long long t;
//    while((pow(t, n-1)*1ll) <= sum) {t++;}
    //cout<<t<<endl;
    for(long long i = 1; i*i <= sum*2; i++){
        //cout<<i<<endl;
        long long s = 0;
        for(long long j = 0; j < n; j++){
            s = s + abs(a[j] - pow(i,j)*1ll);
            //cout<<s<<" ";
        }
        //cout<<endl;
        if(ans > s) ans = s;
        else break;
        //ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    if(!ans && !fl) ans = 1;
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e15 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    bool fl = true;
    for(int i = 0; i < n - 1; i++) if(a[i] > a[i + 1]){
        fl = false;
        break;
    }
    sort(a, a + n);
    long long t = sqrt(ma);
    for(long long i = 1; i <= t+1; i++){
        //cout<<i<<endl;
        long long s = 0;
        for(long long j = 0; j < n; j++){
            s = s + abs(a[j] - pow(i,j)*1ll);
            //cout<<s<<" ";
        }
        //cout<<endl;
        if(ans > s) ans = s;
        else {break;}
        //ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    //if(!ans && !fl) ans = 1;
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 2e5 + 1;
long long a[MX], l[MX], r[MX];
long long power(long long a, long long n){
    long long s = 1;
    for(long long i = 0; i < n; i++) s = s*a;
    return s;
}
int main(){
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i];
    long long sum = 0, mx = 0;
    sort(a, a+n);
    for(int i = 0; i < n; i++){
        sum += a[i] - 1ll;
        mx = max(mx, a[i]);
    }
    long long mi = 1e18 + 1;
    long long d = 0;
    while(power(d, n - 1) < mx + sum) d++;
    for(long long i = 1; i <= d; i++){
        long long ans = 0;
        for(long long j = 0 ; j < n; j++) ans += abs(a[j] - power(i, j));
        mi = min(ans, mi);
    }
    cout<<mi;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 2e5 + 1;
long long a[MX], l[MX], r[MX];
long long power(long long a, int n){
    long long s = 1;
    for(int i = 0; i < n; i++) s = s * a;
    return s;
}
int main(){
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i];
    long long sum = 0, mx = 0;
    sort(a, a+n);
    for(int i = 0; i < n; i++){
        sum += a[i] - 1ll;
        mx = max(mx, a[i]);
    }
    long long mi = 1e18 + 1ll;
    long long d = 1;
    while(pow(d, n - 1) <= (mx + sum)) d++;
    for(long long i = 1; i <= d; i++){
        long long ans = 0;
        for(int j = 0 ; j < n; j++) ans += abs(a[j] - pow(i, j));
        if(ans < mi) mi = ans;
        else break;
    }
    cout<<mi;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 2e5 + 1;
long long a[MX], l[MX], r[MX];
long long power(long long a, long long n){
    long long s = 1;
    for(long long i = 0; i < n; i++) s = s*a;
    return s;
}
int main(){
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i];
    long long sum = 0, mx = 0;
    sort(a, a+n);
    for(int i = 0; i < n; i++){
        sum += a[i] - 1ll;
        mx = max(mx, a[i]);
    }
    long long mi = 1e18 + 1ll;
    long long d = 0;
    while(power(d, n - 1ll) <= (mx + sum)) d++;
    for(long long i = 1; i <= d; i++){
        long long ans = 0;
        for(long long j = 0 ; j < n; j++) ans += abs(a[j] - power(i, j));
        mi = min(ans, mi);
    }
    cout<<mi;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 2e5 + 1;
long long a[MX], l[MX], r[MX];
long long power(long long a, long long n){
    long long s = 1;
    for(int i = 0; i < n; i++) s = s*a;
    return s;
}
int main(){
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i];
    long long sum = 0, mx = 0;
    sort(a, a+n);
    for(int i = 0; i < n; i++){
        sum += a[i] - 1ll;
        mx = max(mx, a[i]);
    }
    long long mi = 1e18 + 1;
    long long d = 0;
    while(power(d, n - 1) < mx + sum) d++;
    for(long long i = 1; i <= d; i++){
        long long ans = 0;
        for(long long j = 0 ; j < n; j++) ans += abs(a[j] - power(i, j));
        mi = min(ans, mi);
    }
    cout<<mi;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
long long power(long long a, long long b){
    long long s = 1;
    for(long long i = 0; i < b; i++) s = s * a;
    return s;
}
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e18 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    bool fl = true;
    for(int i = 0; i < n - 1; i++) if(a[i] > a[i + 1]){
        fl = false;
        break;
    }
    sort(a, a + n);
    long long t = sqrt(ma);
    for(long long i = t; i <= ma; i++){
        long long s = 0;
        for(long long j = 0; j < n; j++){
            long long p = power(i, j);
            s = s + max(a[j] - p, p - a[j]);
            //cout<<s<<" ";
        }
        //cout<<endl;
        if(ans > s) ans = s;
        else {break;}
        //ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    //if(!ans && !fl) ans = 1;
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e15 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    sort(a, a + n);
    long long t = 0;
    while((pow(t, n-1)*1ll) <= sum) t++;
    for(long long i = 1; i <= t; i++){
        //cout<<i<<endl;
        long long s = 0;
        for(long long j = 0; j < n; j++){
            s = s + abs(a[j] - pow(i,j)*1ll);
            //cout<<s<<" ";
        }
        //cout<<endl;
        ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 2e5 + 1;
long long a[MX], l[MX], r[MX];
long long power(long long a, long long n){
    long long s = 1;
    for(int i = 0; i < n; i++) s = s*a;
    return s;
}
int main(){
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i];
    long long sum = 0, mx = 0;
    sort(a, a+n);
    for(int i = 0; i < n; i++){
        sum += a[i] - 1;
        mx = max(mx, a[i]);
    }
    long long mi = 1e18 + 1;
    long long d = 0;
    while(power(d, n - 1) < mx + sum) d++;
    for(long long i = 1; i <= d; i++){
        long long ans = 0;
        for(long long j = 0 ; j < n; j++) ans += abs(a[j] - power(i, j));
        mi = min(ans, mi);
    }
    cout<<mi;
}


#include <bits/stdc++.h>
using namespace std;
int const MX = 1e5 + 1;
long long a[MX];
long long power(long long a, long long b){
    long long s = 1;
    for(long long i = 0; i < b; i++) s = s * a;
    return s;
}
int main(){
    int n;
    cin>>n;
    long long sum = 0,ans = 1e15 + 1, ma = 0;
    for(int i = 0; i < n; i++) {cin>>a[i];sum+= a[i];ma = max(ma, a[i]);}
    bool fl = true;
    for(int i = 0; i < n - 1; i++) if(a[i] > a[i + 1]){
        fl = false;
        break;
    }
    sort(a, a + n);
    long long t = 1;
    //while(power(t, n - 1) <= ma) t++;
    for(long long i = 1; i <= ma; i++){
        long long s = 0;
        for(long long j = 0; j < n; j++){
            long long p = power(i, j);
            s = s + max(a[j] - p, p - a[j]);
            //cout<<s<<" ";
        }
        //cout<<endl;
        if(ans >= s) ans = s;
        else {break;}
        //ans = min(ans, s);
        //cout<<ans<<"\n";
    }
    //if(!ans && !fl) ans = 1;
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll ipow(ll base, ll exp)
{
    ll result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	ll c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 //c2=int(nthRoot(vec[n-1],n-1));
	//cout<<mac<<endl;
	for(ll i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(ll i=0;i<n;i++){
	    long long int p2=ipow(c1+1,i);
	    minc2+=abs(vec[i]-p2);
	    	}
	    	long long int minc3=0;
	    		for(ll i=0;i<n;i++){
	    long long int p3=ipow(c1-1,i);
	    minc3+=abs(vec[i]-p3);
	    	}
       long long int ans=min({minc1,minc2,minc3});
       cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int ipow(int base, int exp)
{
    int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	map<int,int>mp;
	int c;
	for(int i=n-1;i>0;i--){
	 c=ceil(nthRoot(vec[i],i));
	mp[c]++;
	}
	int max=0;
	int mac=0;
	for(auto x:mp){
	    if(max<x.second){
	        max=x.second;
	        mac=x.first;
	    }
	}
	//cout<<mac<<endl;
	for(int i=0;i<n;i++){
	    long long int p=ipow(mac,i);
	    minc+=abs(vec[i]-p);
	}
	cout<<minc<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int ipow(int base, int exp)
{
    int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	map<int,int>mp1;
	map<int,int>mp2;
	int c1,c2;
	for(int i=n-1;i>0;i--){
	 c1=ceil(nthRoot(vec[i],i));
	mp1[c1]++;

	}
	for(int i=n-1;i>0;i--){
	 c2=floor(nthRoot(vec[i],i));
	mp2[c2]++;

	}
	int max1=0,max2=0;
	int mac1=0,mac2=0;
	for(auto x:mp1){
	    if(max1<x.second){
	        max1=x.second;
	        mac1=x.first;
	    }
	}

	for(auto x:mp2){
	    if(max2<x.second){
	        max2=x.second;
	        mac2=x.first;
	    }
	}
	//cout<<mac<<endl;
	for(int i=0;i<n;i++){
	    long long int p1=ipow(mac1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(int i=0;i<n;i++){
	    long long int p2=ipow(mac2,i);
	    minc2+=abs(vec[i]-p2);

	}
        if(minc1>minc2){
           cout<<minc2<<endl;
        }
        else{
            cout<<minc1<<endl;
        }

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
unsigned int ipow(int base, int exp)
{
    unsigned int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	unsigned long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	int c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 c2=int(nthRoot(vec[n-1],n-1));
	 //cout<<c1<<" "<<c2<<endl;
	//cout<<mac<<endl;
	for(int i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(int i=0;i<n;i++){
	    long long int p2=ipow(c2,i);
	    minc2+=abs(vec[i]-p2);

	}
	unsigned long long int minc3=0;
	for(int i=0;i<n;i++){
	    long long int p3=ipow(c1+1,i);
	    minc3+=abs(vec[i]-p3);

	}
        unsigned long long int ans=min({minc1,minc2,minc3});

        cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long int ipow(long long int base,long long int exp)
{
    long long int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	unsigned long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	long long int c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 c2=int(nthRoot(vec[n-1],n-1));
	 //cout<<c1<<" "<<c2<<endl;
	//cout<<mac<<endl;
	for(long long int i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(long long int i=0;i<n;i++){
	    long long int p2=ipow(c2,i);
	    minc2+=abs(vec[i]-p2);

	}
	unsigned long long int minc3=0;
	for(long long int i=0;i<n;i++){
	    long long int p3=ipow(c1+1,i);
	    minc3+=abs(vec[i]-p3);

	}
        unsigned long long int ans=min({minc1,minc2,minc3});

        cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int ipow(int base, int exp)
{
    int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	int c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 c2=int(nthRoot(vec[n-1],n-1));
	 //cout<<c1<<" "<<c2<<endl;
	//cout<<mac<<endl;
	for(int i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(int i=0;i<n;i++){
	    long long int p2=ipow(c2,i);
	    minc2+=abs(vec[i]-p2);

	}
	long long int minc3=0;
	for(int i=0;i<n;i++){
	    long long int p3=ipow(c1+1,i);
	    minc3+=abs(vec[i]-p3);

	}
        long long int ans=min({minc1,minc2,minc3});

        cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll ipow(ll base, ll exp)
{
    ll result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	ll c1,c2;
	 c1=int(nthRoot(vec[n-1],n-1));
	 //c2=int(nthRoot(vec[n-1],n-1));
	//cout<<mac<<endl;
	for(ll i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(ll i=0;i<n;i++){
	    long long int p2=ipow(c1+1,i);
	    minc2+=abs(vec[i]-p2);
	    	}
	    	long long int minc3=0;
	    		for(ll i=0;i<n;i++){
	    long long int p3=ipow(c1-1,i);
	    minc3+=abs(vec[i]-p3);
	    	}
       long long int ans=min({minc1,minc2,minc3});
       cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
//	OJ;
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
ll int c=0;
for(ll int i=1;pow(i,n-1)<=a[n-1];i++)
{
c=i;
}
//cout<<c<<endl;
unsigned ll int x=0,y=0,z=0,as;
//cout<<c<<endl;
for(int i=n-1;i>=1;i--)
{
  x+=abs(a[i]-pow(c,i));
}
for(int i=n-1;i>=1;i--)
{
  y+=abs(a[i]-pow(c+1,i));
}
for(int i=n-1;i>=1;i--)
{
  z+=abs(a[i]-pow(c-1,i));
}
as=min({x,y,z});
as+=abs(a[0]-1);
cout<<as;
   }


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll ipow(ll base, ll exp)
{
    ll result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	ll c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 //c2=int(nthRoot(vec[n-1],n-1));
	//cout<<mac<<endl;
	for(ll i=0;i<n;i++){
	    long long int p1=pow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(ll i=0;i<n;i++){
	    long long int p2=pow(c1+1,i);
	    minc2+=abs(vec[i]-p2);
	    	}
	    	long long int minc3=0;
	    		for(ll i=0;i<n;i++){
	    long long int p3=pow(c1-1,i);
	    minc3+=abs(vec[i]-p3);
	    	}
       long long int ans=min({minc1,minc2,minc3});
       cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int ipow(int base, int exp)
{
    int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	unsigned long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	int c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 c2=int(nthRoot(vec[n-1],n-1));
	 //cout<<c1<<" "<<c2<<endl;
	//cout<<mac<<endl;
	for(int i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(int i=0;i<n;i++){
	    long long int p2=ipow(c2,i);
	    minc2+=abs(vec[i]-p2);

	}
	unsigned long long int minc3=0;
	for(int i=0;i<n;i++){
	    long long int p3=ipow(c1+1,i);
	    minc3+=abs(vec[i]-p3);

	}
        unsigned long long int ans=min({minc1,minc2,minc3});

        cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
//	OJ;
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
ll int c=0;
for(ll int i=1;pow(i,n-1)<=a[n-1];i++)
{
c=i;
}
cout<<c<<endl;
unsigned ll int x=0,y=0,z=0,ans;
//cout<<c<<endl;
for(int i=n-1;i>=1;i--)
{
  x+=abs(a[i]-pow(c,i));
}
for(int i=n-1;i>=1;i--)
{
  y+=abs(a[i]-pow(c+1,i));
}
for(int i=n-1;i>=1;i--)
{
  z+=abs(a[i]-pow(c-1,i));
}
as=min({x,y,z});
as+=abs(a[0]-1);
cout<<as;
   }


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
//	OJ;
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
ll int c=0;
for(ll int i=1;pow(i,n-1)<=a[n-1];i++)
{
c=i;
}
cout<<c<<endl;
unsigned ll int x=0,y=0,z=0,as;
//cout<<c<<endl;
for(int i=n-1;i>=1;i--)
{
  x+=abs(a[i]-pow(c,i));
}
for(int i=n-1;i>=1;i--)
{
  y+=abs(a[i]-pow(c+1,i));
}
for(int i=n-1;i>=1;i--)
{
  z+=abs(a[i]-pow(c-1,i));
}
as=min({x,y,z});
as+=abs(a[0]-1);
cout<<as;
   }


#include <bits/stdc++.h>
using namespace std;
int ipow(int base, int exp)
{
    int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	int c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 c2=int(nthRoot(vec[n-1],n-1));
	//cout<<mac<<endl;
	for(int i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(int i=0;i<n;i++){
	    long long int p2=ipow(c2,i);
	    minc2+=abs(vec[i]-p2);

	}
        if(minc1>minc2){
           cout<<minc2<<endl;
        }
        else{
            cout<<minc1<<endl;
        }

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
unsigned long long int  ipow(unsigned long long int base,unsigned long long int exp)
{
    unsigned long long int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	unsigned long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	unsigned long long int c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 c2=int(nthRoot(vec[n-1],n-1));
	 //cout<<c1<<" "<<c2<<endl;
	//cout<<mac<<endl;
	for(unsigned long long int i=0;i<n;i++){
	    unsigned long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(unsigned long long int i=0;i<n;i++){
	    unsigned long long int p2=ipow(c2,i);
	    minc2+=abs(vec[i]-p2);

	}
	unsigned long long int minc3=0;
	for(unsigned long long int i=0;i<n;i++){
	    unsigned long long int p3=ipow(c1+1,i);
	    minc3+=abs(vec[i]-p3);

	}
        long long int ans=min({minc1,minc2,minc3});

        cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll ipow(ll base, ll exp)
{
    ll result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	ll c1,c2;
	 c1=int(nthRoot(vec[n-1],n-1));
	 //c2=int(nthRoot(vec[n-1],n-1));
	//cout<<mac<<endl;
	for(ll i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(ll i=0;i<n;i++){
	    long long int p2=ipow(c1+1,i);
	    minc2+=abs(vec[i]-p2);
	    	}
	    	long long int minc3=0;
	    		for(ll i=0;i<n;i++){
	    long long int p3=ipow(c1-1,i);
	    minc3+=abs(vec[i]-p3);
	    	}
       int ans=min((min(minc1,minc2)),minc3);
       cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long int ipow(int base, int exp)
{
    long long int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	unsigned long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	int c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 c2=int(nthRoot(vec[n-1],n-1));
	 //cout<<c1<<" "<<c2<<endl;
	//cout<<mac<<endl;
	for(int i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(int i=0;i<n;i++){
	    long long int p2=ipow(c2,i);
	    minc2+=abs(vec[i]-p2);

	}
	unsigned long long int minc3=0;
	for(int i=0;i<n;i++){
	    long long int p3=ipow(c1+1,i);
	    minc3+=abs(vec[i]-p3);

	}
        unsigned long long int ans=min({minc1,minc2,minc3});

        cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int ipow(int base, int exp)
{
    int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<int>vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	int minc=0;
	int c=ceil(nthRoot(vec[n-1],n-1));
	for(int i=0;i<n;i++){
	    int p=ipow(c,i);
	    minc+=abs(vec[i]-p);
	}
	cout<<minc<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int ipow(int base, int exp)
{
    int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	int c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 //c2=int(nthRoot(vec[n-1],n-1));
	//cout<<mac<<endl;
	for(int i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(int i=0;i<n;i++){
	    long long int p2=ipow(c1+1,i);
	    minc2+=abs(vec[i]-p2);
	    	}
	    	long long int minc3=0;
	    		for(int i=0;i<n;i++){
	    long long int p3=ipow(c1-1,i);
	    minc3+=abs(vec[i]-p3);
	    	}
       int ans=min((min(minc1,minc2)),minc3);
       cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long int  ipow(long long int base,long long int exp)
{
    long long int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	long long int c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 c2=int(nthRoot(vec[n-1],n-1));
	 //cout<<c1<<" "<<c2<<endl;
	//cout<<mac<<endl;
	for(long long int i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(long long int i=0;i<n;i++){
	    long long int p2=ipow(c2,i);
	    minc2+=abs(vec[i]-p2);

	}
	long long int minc3=0;
	for(long long int i=0;i<n;i++){
	    long long int p3=ipow(c1+1,i);
	    minc3+=abs(vec[i]-p3);

	}
        long long int ans=min({minc1,minc2,minc3});

        cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll ipow(ll base, ll exp)
{
    ll result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	ll c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 //c2=int(nthRoot(vec[n-1],n-1));
	//cout<<mac<<endl;
	for(ll i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(ll i=0;i<n;i++){
	    long long int p2=ipow(c1+1,i);
	    minc2+=abs(vec[i]-p2);
	    	}
	    	long long int minc3=0;
	    		for(ll i=0;i<n;i++){
	    long long int p3=ipow(c1-1,i);
	    minc3+=abs(vec[i]-p3);
	    	}
       int ans=min((min(minc1,minc2)),minc3);
       cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int ipow(int base, int exp)
{
    int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	int c1,c2;
	 c1=ceil(nthRoot(vec[n-1],n-1));
	 c2=int(nthRoot(vec[n-1],n-1));
	//cout<<mac<<endl;
	for(int i=0;i<n;i++){
	    long long int p1=ipow(c1,i);
	    minc1+=abs(vec[i]-p1);

	}

     	for(int i=0;i<n;i++){
	    long long int p2=ipow(c2,i);
	    minc2+=abs(vec[i]-p2);

	}
	long long int minc3=0;
	for(int i=0;i<n;i++){
	    long long int p3=ipow(c2-1,i);
	    minc3+=abs(vec[i]-p3);

	}
        long long int ans=min({minc1,minc2,minc3});

        cout<<ans<<endl;

	//cout<<minc1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int ipow(int base, int exp)
{
    int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	map<int,int>mp;
	int c;
	for(int i=1;i<n;i++){
	 c=ceil(nthRoot(vec[n-1],n-1));
	mp[c]++;
	}
	int max=0;
	int mac=0;
	for(auto x:mp){
	    if(max<x.second){
	        max=x.second;
	        mac=x.first;
	    }
	}
	//cout<<mac<<endl;
	for(int i=0;i<n;i++){
	    long long int p=ipow(mac,i);
	    minc+=abs(vec[i]-p);
	}
	cout<<minc<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int ipow(int base, int exp)
{
    int result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

double nthRoot(int A, int N)
{
    // intially guessing a random number between
    // 0 and 9
    double xPre = rand() % 10;

    //  smaller eps, denotes more accuracy
    double eps = 1e-3;

    // initializing difference between two
    // roots by INT_MAX
    double delX = INT_MAX;

    //  xK denotes current value of x
    double xK;

    //  loop untill we reach desired accuracy
    while (delX > eps)
    {
        //  calculating current value from previous
        // value by newton's method
        xK = ((N - 1.0) * xPre +
              (double)A/pow(xPre, N-1)) / (double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
int main() {
	int n;
	cin>>n;

	vector<long long int >vec;
	int a;
	for(int i=0;i<n;i++){
	    cin>>a;
	    vec.push_back(a);
	}

	sort(vec.begin(),vec.end());

	long long int minc1=0,minc2=0;
	//int c=ceil(nthRoot(vec[n-1],n-1));
	map<int,int>mp;
	int c;
	for(int i=n-1;i>0;i--){
	 c=ceil(nthRoot(vec[i],i));
	mp[c]++;
	c=int(nthRoot(vec[i],i));
	mp[c]++;
	}
	int max=0;
	int mac=0;
	for(auto x:mp){
	    if(max<x.second){
	        max=x.second;
	        mac=x.first;
	    }
	}
	//cout<<mac<<endl;
	for(int i=0;i<n;i++){
	    long long int p1=ipow(mac,i);
	    minc1+=abs(vec[i]-p1);

	}
	for(int i=0;i<n;i++){
	    long long int p2=1;
	    minc2+=abs(vec[i]-p2);

	}

	long long int ans=min(minc1,minc2);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include<string>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i,count1=0,count2=0,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	long long k=n-1,max1;
	max1=ceil(pow(k,
               (1.0 / k)
                   * (log(a[n-1])
                      / log(k))));
    //cout<<max1<<endl;
    for(j=1;j<=(max1+1);j++)
    {
        count1=0;
        for(i=0;i<n;i++)
        {
            count1+=abs(pow(j,i)-a[i]);
        }
        if(j==1) count2=count1;
        else count2=min(count2,count1);
    }
    cout<<count2<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include<string>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i,count1=0,count2=1e18,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	long long x;
	i=1;
	while(1)
	{
	    x=pow(i,n-1);
	    if(x>a[n-1]) break;
	    i++;
	}
	x=i;
    for(j=max(x-3,1);j<=x+2;j++)
    {
        count1=0;
        for(i=0;i<n;i++)
        {
            count1+=abs(pow(j,i)-a[i]);
        }
        count2=min(count2,count1);
    }
    cout<<count2<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i=1,x,count,ans=1e18,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for(i=1;i<=1000000;i++)
	{
	        count=0;
	        for(j=0;j<n;j++)
	        {
	            count+=abs(pow(i,j)-a[j]);
	            if(count>ans) break;
	        }
	        if(count<ans) ans=count;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include<string>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i,count1=0,count2=1e18,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
    for(j=1;j<=60;j++)
    {
        count1=0;
        for(i=0;i<n;i++)
        {
            count1+=abs(pow(j,i)-a[i]);
        }
        count2=min(count2,count1);
    }
    cout<<count2<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include<string>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i,count1=0,count2=1e18,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	long long x=(6000000/n);
    for(j=1;j<=x;j++)
    {
        count1=0;
        for(i=0;i<n;i++)
        {
            count1+=abs(pow(j,i)-a[i]);
        }
        count2=min(count2,count1);
    }
    cout<<count2<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include<string>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i,count1=0,count2=0,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	long long k=n-1,max1;
	max1=ceil(pow(k,
               (1.0 / k)
                   * (log(a[n-1])
                      / log(k))));
    //cout<<max1<<endl;
    if(n>2)
    {
    for(j=1;j<=max1;j++)
    {
        count1=0;
        for(i=0;i<n;i++)
        {
            count1+=abs(pow(j,i)-a[i]);
        }
        if(j==1) count2=count1;
        else count2=min(count2,count1);
    }
    }
    else
    {
        count2=abs(a[0]-1);
    }
    cout<<count2<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include<string>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i,count1=0,count2=1e18,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	long long k=n-1,max1;
	double x=(double) a[n-1];
	max1=ceil(pow(k,
               (1.0 / k)
                   * (log(x)
                      / log(k))));
    //cout<<max1<<endl;
    for(j=1;j<=(max1+2);j++)
    {
        count1=0;
        for(i=0;i<n;i++)
        {
            count1+=abs(pow(j,i)-a[i]);
        }
        count2=min(count2,count1);
    }
    cout<<count2<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i=1,x,count,ans=1e18,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	while(1)
	{
	    x=pow(i,n-1);
	    if(x>1e14) break;
	    else
	    {
	        count=0;
	        for(j=0;j<n;j++)
	        {
	            count+=abs(pow(i,j)-a[j]);
	        }
	        if(count<ans) ans=count;
	        i++;
	    }
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include<string>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i,count1=0,count2=0,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	long long k=n-1,max1;
	max1=ceil(pow(k,
               (1.0 / k)
                   * (log(a[n-1])
                      / log(k))));
    for(j=1;j<=max1;j++)
    {
        count1=0;
        for(i=0;i<n;i++)
        {
            count1+=abs(pow(j,i)-a[i]);
        }
        if(j==1) count2=count1;
        else count2=min(count2,count1);
    }
    cout<<count2<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include<string>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i,count1=0,count2=1e18,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	long long k=n-1,max1;
	double x=(double) a[n-1];
	max1=ceil(pow(k,
               (1.0 / k)
                   * (log(x)
                      / log(k))));
    //cout<<max1<<endl;
    for(j=1;j<=(max1+1);j++)
    {
        count1=0;
        for(i=0;i<n;i++)
        {
            count1+=abs(pow(j,i)-a[i]);
        }
        count2=min(count2,count1);
        //cout<<count2<<" "<<j<<endl;
        }
    cout<<count2<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include<string>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i,count1=0,count2=1e18,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	long long k=n-1,max1;
	double x=(double) a[n-1];
	max1=ceil(pow(k,
               (1.0 / k)
                   * (log(x)
                      / log(k))));
    //cout<<max1<<endl;
    for(j=0;j<=(max1+1);j++)
    {
        count1=0;
        for(i=0;i<n;i++)
        {
            count1+=abs(pow(j,i)-a[i]);
            if(count1>count2) break;
        }
        count2=min(count2,count1);
        //cout<<count2<<" "<<j<<endl;
        }
    cout<<count2<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include<string>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i,count1=0,count2=1e18,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	long long k=n-1,max1;
	long long x;
	i=1;
	while(1)
	{
	    x=pow(i,n-1);
	    if(x>a[n-1]) break;
	    i++;
	}
	max1=i;
    //cout<<max1<<endl;
    for(j=1;j<=(max1+1);j++)
    {
        count1=0;
        for(i=0;i<n;i++)
        {
            count1+=abs(pow(j,i)-a[i]);
        }
        count2=min(count2,count1);
        //cout<<count2<<" "<<j<<endl;
        }
    cout<<count2<<endl;
	return 0;
}


#include<bits/stdc++.h>
#include<string>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long n;cin>>n;
	long long a[n],i,count1=0,count2=0;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	long long k=n-1,max1,max2;
	max1=ceil(pow(k,
               (1.0 / k)
                   * (log(a[n-1])
                      / log(k))));
    max2=floor(pow(k,
               (1.0 / k)
                   * (log(a[n-1])
                      / log(k))));
    //cout<<max1<<" "<<max2<<endl;
    for(i=0;i<n;i++)
    {
        count1+=abs((pow(max1,i)-a[i]));
    }
    for(i=0;i<n;i++)
    {
        count2+=abs((pow(max2,i)-a[i]));
    }
    if(count1<count2) cout<<count1<<endl;
    else cout<<count2<<endl;
	return 0;
}


#include <cstdio>
#define nmax 4100
using namespace std;
int n,in[nmax];
int v[nmax],d[nmax];
long long p[nmax],t;
int nr,sol[nmax];

int main()
{
    int i,j,k;
   // freopen("c.in","r",stdin);
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d %d %d",&v[i],&d[i],&p[i]),in[i]=1;

    for (i=1;i<=n;i++)
        if (in[i]==1) {

            in[i]=0;
            k=v[i];t=0;
            sol[++nr]=i;

            for (j=i+1;j<=n;j++)
                if (in[j]==1) {

                    if (p[j]>=0)
                        p[j]-=k+t;
                    if (k>=1)
                        k--;
                    if (p[j]<0) {
                        in[j]=0;
                        t+=d[j];
                    }
                }
        }
    printf("%d\n",nr);
    for (i=1;i<=nr;i++)
        printf("%d ",sol[i]);

    return 0;
}


#include <cstdio>
#define nmax 4100
using namespace std;
int n,in[nmax];
int v[nmax],d[nmax],p[nmax];
int nr,sol[nmax];

void recursion(int i)
{
    in[i]=0;
    int j;
    for (j=i+1;j<=n;j++) {
        p[j]-=d[i];
        if (p[j]<0&&in[j]==1) {
            recursion(j);
        }
    }
}

int main()
{
    freopen("c.in","r",stdin);
    int i,j,k;
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d %d %d",&v[i],&d[i],&p[i]),in[i]=1;

    for (i=1;i<=n;i++)
        if (in[i]==1) {
            k=v[i];
            for (j=i+1;j<=n;j++) {
                if (in[j]==1) {
                    p[j]-=k;
                    k--;
                    if (p[j]<0)
                        recursion(j);
                }
            }
            sol[++nr]=i;
        }
    printf("%d\n",nr);
    for (i=1;i<=nr;i++)
        printf("%d ",sol[i]);

    return 0;
}


#include <cstdio>
#define nmax 4100
using namespace std;
int n,in[nmax];
int v[nmax],d[nmax],p[nmax];
int nr,sol[nmax];

void recursion(int i)
{
    in[i]=0;
    int j;
    for (j=i+1;j<=n;j++) {
        p[j]-=d[i];
        if (p[j]<0&&in[j]==1)
            recursion(j);
    }

}

int main()
{
    int i,j,k;
   // freopen("c.in","r",stdin);
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d %d %d",&v[i],&d[i],&p[i]),in[i]=1;

    for (i=1;i<=n;i++)
        if (in[i]==1) {
            k=v[i];
            sol[++nr]=i;
            for (j=i+1;j<=n;j++) {
                if (in[j]==1) {
                    p[j]-=k;
                    k--;
                    if (in[j]==1&&p[j]<0)
                        recursion(j);
                }
            }
        }
    printf("%d\n",nr);
    for (i=1;i<=nr;i++)
        printf("%d ",sol[i]);

    return 0;
}


#include <cstdio>
#define nmax 4100
using namespace std;
int n,in[nmax];
int v[nmax],d[nmax],p[nmax];
int nr,sol[nmax];

void recursion(int i)
{
    in[i]=0;
    int j;
    for (j=i+1;j<=n;j++)
        p[j]-=d[i];
    for (j=i+1;j<=n;j++)
        if (p[j]<0&&in[j]==1)
            recursion(j);
}

int main()
{
    int i,j,k;
    freopen("c.in","r",stdin);
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d %d %d",&v[i],&d[i],&p[i]),in[i]=1;

    for (i=1;i<=n;i++)
        if (in[i]==1) {
            k=v[i];
            sol[++nr]=i;
            for (j=i+1;j<=n;j++) {
                if (in[j]==1) {
                    p[j]-=k;
                }
                k--;
            }
            for (j=i+1;j<=n;j++)
                if (p[j]<0&&in[j]==1)
                    recursion(j);
        }
    printf("%d\n",nr);
    for (i=1;i<=nr;i++)
        printf("%d ",sol[i]);

    return 0;
}


#include <cstdio>
#define nmax 4100
using namespace std;
int n,in[nmax];
int v[nmax],d[nmax],p[nmax];
int nr,sol[nmax];

void recursion(int i)
{
    in[i]=0;
    int j;
    for (j=i+1;j<=n;j++) {
        if (p[j]>=0)
            p[j]-=d[i];

        if (p[j]<0&&in[j]==1)
            recursion(j);
    }

}

int main()
{
    int i,j,k;
    //freopen("c.in","r",stdin);
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d %d %d",&v[i],&d[i],&p[i]),in[i]=1;

    for (i=1;i<=n;i++)
        if (in[i]==1) {
            in[i]=0;
            k=v[i];
            sol[++nr]=i;
            for (j=i+1;j<=n;j++) {
                if (in[j]==1) {

                    if (p[j]>=0)
                        p[j]-=k;
                    k--;

                }
            }
            for (j=i+1;j<=n;j++)
                 if (in[j]==1&&p[j]<0)
                        recursion(j);
        }
    printf("%d\n",nr);
    for (i=1;i<=nr;i++)
        printf("%d ",sol[i]);

    return 0;
}


#include <cstdio>
#define nmax 4100
using namespace std;
int n,in[nmax];
int v[nmax],d[nmax],p[nmax];
int nr,sol[nmax];

void recursion(int i)
{
    in[i]=0;
    int j;
    for (j=i+1;j<=n;j++) {
        p[j]-=d[i];
        if (p[j]<0&&in[j]==1) {
            recursion(j);
        }
    }
}

int main()
{
    int i,j,k;
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d %d %d",&v[i],&d[i],&p[i]),in[i]=1;

    for (i=1;i<=n;i++)
        if (in[i]==1) {
            k=v[i];
            for (j=i+1;j<=n;j++) {
                if (in[j]==1) {
                    p[j]-=k;
                    k--;
                    if (p[j]<0)
                        recursion(j);
                }
            }
            sol[++nr]=i;
        }
    printf("%d\n",nr);
    for (i=1;i<=nr;i++)
        printf("%d ",sol[i]);

    return 0;
}


#include <cstdio>
#define nmax 4100
using namespace std;
int n,in[nmax];
int v[nmax],d[nmax];
long long p[nmax];
int nr,sol[nmax];

int main()
{
    int i,j,k,t;
   // freopen("c.in","r",stdin);
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d %d %d",&v[i],&d[i],&p[i]),in[i]=1;

    for (i=1;i<=n;i++)
        if (in[i]==1) {

            in[i]=0;
            k=v[i];t=0;
            sol[++nr]=i;

            for (j=i+1;j<=n;j++)
                if (in[j]==1) {
                    p[j]-=k+t;
                    if (k>=1)
                        k--;
                    if (p[j]<0) {
                        in[j]=0;
                        t+=d[j];
                    }
                }
        }
    printf("%d\n",nr);
    for (i=1;i<=nr;i++)
        printf("%d ",sol[i]);

    return 0;
}


#include <cstdio>
#define nmax 4100
using namespace std;
int n,in[nmax];
int v[nmax],d[nmax];
long long p[nmax];
int nr,sol[nmax];

int main()
{
    int i,j,k,t;
   // freopen("c.in","r",stdin);
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d %d %d",&v[i],&d[i],&p[i]),in[i]=1;

    for (i=1;i<=n;i++)
        if (in[i]==1) {

            in[i]=0;
            k=v[i];t=0;
            sol[++nr]=i;

            for (j=i+1;j<=n;j++)
                if (in[j]==1) {

                    if (p[j]>=0)
                        p[j]-=k+t;
                    if (k>=1)
                        k--;
                    if (p[j]<0) {
                        in[j]=0;
                        t+=d[j];
                    }
                }
        }
    printf("%d\n",nr);
    for (i=1;i<=nr;i++)
        printf("%d ",sol[i]);

    return 0;
}


#include <cstdio>
#define nmax 4100
using namespace std;
int n,in[nmax];
int v[nmax],d[nmax],p[nmax];
int nr,sol[nmax];

void recursion(int i)
{
    in[i]=0;
    int j;
    for (j=i+1;j<=n;j++)
        p[j]-=d[i];
    for (j=i+1;j<=n;j++)
        if (p[j]<0&&in[j]==1)
            recursion(j);
}

int main()
{
    int i,j,k;
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d %d %d",&v[i],&d[i],&p[i]),in[i]=1;

    for (i=1;i<=n;i++)
        if (in[i]==1) {
            k=v[i];
            sol[++nr]=i;
            for (j=i+1;j<=n;j++) {
                if (in[j]==1) {
                    p[j]-=k;
                }
                k--;
            }
            for (j=i+1;j<=n;j++)
                if (p[j]<0&&in[j]==1)
                    recursion(j);
        }
    printf("%d\n",nr);
    for (i=1;i<=nr;i++)
        printf("%d ",sol[i]);

    return 0;
}


#include <cstdio>
#define nmax 4100
using namespace std;
int n,in[nmax];
int v[nmax],d[nmax],p[nmax];
int nr,sol[nmax];

void recursion(int i)
{
    in[i]=0;
    int j;
    for (j=i+1;j<=n;j++)
        p[j]-=d[i];
    for (j=i+1;j<=n;j++)
        if (p[j]<0&&in[j]==1)
            recursion(j);
}

int main()
{
    int i,j,k;
   // freopen("c.in","r",stdin);
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d %d %d",&v[i],&d[i],&p[i]),in[i]=1;

    for (i=1;i<=n;i++)
        if (in[i]==1) {
            k=v[i];
            sol[++nr]=i;
            for (j=i+1;j<=n;j++) {
                if (in[j]==1) {
                    p[j]-=k;
                    k--;
                }
            }
            for (j=i+1;j<=n;j++)
                if (p[j]<0&&in[j]==1)
                    recursion(j);
        }
    printf("%d\n",nr);
    for (i=1;i<=nr;i++)
        printf("%d ",sol[i]);

    return 0;
}