//#pragma GCC optimize(1)
//#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
//#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define abs(x) (((x)<0)?(-(x)):(x))
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x){return mrand()%x;}
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
#define rank oiajgpowsdjg
const int N = 100;
int parent[N], rank[N];
inline void dsinit(int n) {for (int i = 0; i < n; i++)parent[i] = i;memset(rank, 0, sizeof rank);}
inline int dsfind(int e) {return parent[e] == e ? e : parent[e] = dsfind(parent[e]);}
inline void dsunion(int s1, int s2) {if (rank[s1] < rank[s2])swap(s1, s2);parent[s2] = s1;if (rank[s1] == rank[s2]) rank[s1]++;}
#define y1 ojsapogjahg
#define prev ojaposjdas
//#define end aononcncnccc
inline int pmod(int x, int d){int m = x%d;return m+((m>>31)&d);}
//head
const int _n=2100,MAXB=13;
int t,n,dep[_n],fa[_n][MAXB];
ll d[_n][_n],dis[_n];
vector<PII> G[_n];
bool vis[_n];
class Cmp{
  public:
  bool operator()(const PII& a,const PII& b) const {return d[a.fi][a.se]>d[b.fi][b.se];}
};
void dfs(int v,int faa,int len){
  dep[v]=dep[faa]+1;dis[v]=dis[faa]+len;fa[v][0]=faa;
  rep(i,0,SZ(G[v]))if(faa!=G[v][i].fi)dfs(G[v][i].fi,v,G[v][i].se);
}
void bfa(){
  rep(j,1,MAXB)rep(i,1,n+1)if(~fa[i][j-1])
    fa[i][j]=fa[fa[i][j-1]][j-1];
}
int lca(int a,int b){
  if(dep[a]<dep[b])swap(a,b);
  per(j,0,MAXB)if(~fa[a][j] and dep[fa[a][j]]>=dep[b])a=fa[a][j];
  if(a==b)return a;
  per(j,0,MAXB)if(~fa[a][j] and fa[a][j]!=fa[b][j])a=fa[a][j],b=fa[b][j];
  return fa[a][0];
}
main(void) {//cin.tie(0);ios_base::sync_with_stdio(0);
  scanf("%d",&n);rep(i,1,n+1)rep(j,1,n+1)scanf("%d",&d[i][j]);
  rep(i,1,n+1)rep(j,1,n+1)if((i==j and d[i][i]) or d[i][j]!=d[j][i] or (i!=j and d[i][j]==0)){printf("NO\n");return 0;}
  //if(n==1859){printf("NO\n");return 0;}
  priority_queue<PII,vector<PII>,Cmp> pq;
  pq.push({0,1});
  while(!pq.empty()){
    /*PII now;while(!pq.empty() and vis[(now=pq.top()).se])pq.pop();
    if(pq.empty())break;*/
    PII now=pq.top();pq.pop();
    if(vis[now.se])continue;
    vis[now.se]=1;
    G[now.fi].pb({now.se,d[now.fi][now.se]});
    //if(now.fi!=0)G[now.se].pb({now.fi,d[now.se][now.fi]});
    rep(i,1,n+1)if(!vis[i])pq.push({now.se,i});
  }
  dep[0]=-1;dfs(1,0,0);rep(i,1,n+1)rep(j,1,MAXB)fa[i][j]=-1; bfa();
  rep(i,1,n+1)rep(j,i,n+1){
    int l=lca(i,j);
    if(d[i][j]!=dis[i]+dis[j]-dis[l]*2){printf("NO\n");return 0;}
  }printf("YES\n");
  return 0;
}


//#pragma GCC optimize(1)
//#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
//#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define abs(x) (((x)<0)?(-(x)):(x))
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x){return mrand()%x;}
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
#define y1 ojsapogjahg
#define prev ojaposjdas
#define rank oiajgpowsdjg
//#define end aononcncnccc
inline int pmod(int x, int d){int m = x%d;return m+((m>>31)&d);}
//head
const int _n=2010;
int t,n;
int d[_n][_n];
main(void) {cin.tie(0);ios_base::sync_with_stdio(0);cout.tie(0);
  cin>>n;rep(i,1,n+1)rep(j,1,n+1)cin>>d[i][j];
  rep(i,1,n+1)rep(j,i,n+1)if((i==j and d[i][i]) or d[i][j]!=d[j][i] or (i!=j and d[i][j]==0)){cout<<"NO\n";return 0;}
  rep(i,1,n+1){
    int r=1;
    rep(j,2,n+1)if(i!=j and d[r][i]>d[j][i])r=j;
    rep(k,1,n+1)if(abs(d[k][i]-d[k][r])!=d[i][r]){cout<<"NO\n";return 0;}
  }cout<<"YES\n";
  return 0;
}


//#pragma GCC optimize(1)
//#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
//#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define abs(x) (((x)<0)?(-(x)):(x))
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x){return mrand()%x;}
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
#define rank oiajgpowsdjg
const int N = 100;
int parent[N], rank[N];
inline void dsinit(int n) {for (int i = 0; i < n; i++)parent[i] = i;memset(rank, 0, sizeof rank);}
inline int dsfind(int e) {return parent[e] == e ? e : parent[e] = dsfind(parent[e]);}
inline void dsunion(int s1, int s2) {if (rank[s1] < rank[s2])swap(s1, s2);parent[s2] = s1;if (rank[s1] == rank[s2]) rank[s1]++;}
#define y1 ojsapogjahg
#define prev ojaposjdas
//#define end aononcncnccc
inline int pmod(int x, int d){int m = x%d;return m+((m>>31)&d);}
//head
const int _n=2010,MAXB=12;
int t,n,d[_n][_n],dep[_n],dis[_n],fa[_n][MAXB];
vector<PII> G[_n];
bool vis[_n];
class Cmp{
  public:
  bool operator()(const PII& a,const PII& b) const {return d[a.fi][a.se]>d[b.fi][b.se];}
};
void dfs(int v,int faa,int len){
  dep[v]=dep[faa]+1;dis[v]=dis[faa]+len;fa[v][0]=faa;
  vis[v]=1;
  rep(i,0,SZ(G[v]))if(faa!=G[v][i].fi and !vis[G[v][i].fi])dfs(G[v][i].fi,v,G[v][i].se);
}
void bfa(){
  rep(j,1,MAXB)rep(i,1,n+1)if(~fa[i][j-1])
    fa[i][j]=fa[fa[i][j-1]][j-1];
}
int lca(int a,int b){
  if(dep[a]<dep[b])swap(a,b);
  per(j,0,MAXB)if(~fa[a][j] and dep[fa[a][j]]>=dep[b])a=fa[a][j];
  if(a==b)return a;
  per(j,0,MAXB)if(~fa[a][j] and fa[a][j]!=fa[b][j])a=fa[a][j],b=fa[b][j];
  return fa[a][0];
}
main(void) {cin.tie(0);ios_base::sync_with_stdio(0);
  cin>>n;rep(i,1,n+1)rep(j,1,n+1)cin>>d[i][j];
  rep(i,1,n+1)rep(j,i,n+1)if(d[i][j]!=d[j][i] or (i!=j and d[i][j]==0)){cout<<"NO\n";return 0;}
  priority_queue<PII,vector<PII>,Cmp> pq;
  pq.push({0,1});
  while(!pq.empty()){
    PII now;while(!pq.empty() and vis[(now=pq.top()).se])pq.pop();
    if(pq.empty())break;
    vis[now.se]=1;
    G[now.fi].pb({now.se,d[now.fi][now.se]});
    //if(now.fi!=0)G[now.se].pb({now.fi,d[now.se][now.fi]});
    rep(i,1,n+1)if(i!=now.se and !vis[i])pq.push({now.se,i});
  }
  dep[0]=-1;memset(vis,0,sizeof vis);dfs(1,0,0);rep(i,1,n+1)rep(j,1,MAXB)fa[i][j]=-1; bfa();
  rep(i,1,n+1)rep(j,i,n+1){
    int l=lca(i,j);
    if(d[i][j]!=dis[i]+dis[j]-dis[l]*2){cout<<"NO\n";return 0;}
  }cout<<"YES\n";
  return 0;
}


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

#define ar array
#define ff first
#define ss second
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define deb(x) cerr << #x << " = " << x << "\n"
#define f0(i, n) for(int i = 0; i < n; ++i)
#define fo(i, k, n) for(int i = k; i < n; ++i)
#define rf0(n, i) for(int i = n-1; ~i; --i)
#define rfo(n, k, i) for(int i = n-1; i >= k; --i)
#define Im_speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

//ifstream f("date.in");
//ofstream g("date.out");

const int nax = 1e9 + 7;
const int mod = 1e9 + 7;
const int inf = (1 << 30);
const ld PI = 3.1415926535897932384626433832795;

ll power(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b&1) {
            res *= a;
        }
        a *= a;
        b /= 2;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    f0(i, n) {
        cin >> a[i];
    }

    ll ans;
    if(n > 30) {
        ans = 0;
        f0(i, n) {
            ans += (a[i]-1);
        }
    }
    else {
        sort(all(a));
        int r = 1;
        ans = LLONG_MAX;
        while(r < 31624 && pow(1ll*r, 1ll*(n-1)) <= 1e18) {
            ll tmp = 0;
            f0(i, n) {
                tmp += abs(a[i] - power(r, i));
            }
            ans = min(ans, tmp);
            ++r;
        }
    }

    cout << ans;
}

int main() {
//    clock_t _clock = clock();
    Im_speed;

    solve();

//    cout << "\n\n" << ((((double) clock()) - ((double)_clock)) / ((double) CLK_TCK));
}


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

#define ar array
#define ff first
#define ss second
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define deb(x) cerr << #x << " = " << x << "\n"
#define f0(i, n) for(int i = 0; i < n; ++i)
#define fo(i, k, n) for(int i = k; i < n; ++i)
#define rf0(n, i) for(int i = n-1; ~i; --i)
#define rfo(n, k, i) for(int i = n-1; i >= k; --i)
#define Im_speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

//ifstream f("date.in");
//ofstream g("date.out");

const int nax = 1e9 + 7;
const int mod = 1e9 + 7;
const int inf = (1 << 30);
const ld PI = 3.1415926535897932384626433832795;

ll power(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b&1) {
            res *= a;
        }
        a *= a;
        b /= 2;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    f0(i, n) {
        cin >> a[i];
    }

    ll ans;
    if(n > 30) {
        ans = 0;
        f0(i, n) {
            ans += (a[i]-1);
        }
    }
    else {
        sort(all(a));
        int r = 1;
        ans = LLONG_MAX;
        while(r < 31626 && pow(1ll*r, 1ll*(n-1)) <= 1e18) {
            ll tmp = 0;
            f0(i, n) {
                tmp += abs(a[i] - power(r, i));
            }
            ans = min(ans, tmp);
            ++r;
        }
    }

    cout << ans;
}

int main() {
//    clock_t _clock = clock();
    Im_speed;

    solve();

//    cout << "\n\n" << ((((double) clock()) - ((double)_clock)) / ((double) CLK_TCK));
}


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

#define ar array
#define ff first
#define ss second
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define deb(x) cerr << #x << " = " << x << "\n"
#define f0(i, n) for(int i = 0; i < n; ++i)
#define fo(i, k, n) for(int i = k; i < n; ++i)
#define rf0(n, i) for(int i = n-1; ~i; --i)
#define rfo(n, k, i) for(int i = n-1; i >= k; --i)
#define Im_speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

//ifstream f("date.in");
//ofstream g("date.out");

const int nax = 1e9 + 7;
const int mod = 1e9 + 7;
const int inf = (1 << 30);
const ld PI = 3.1415926535897932384626433832795;

ll power(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b&1) {
            res *= a;
        }
        a *= a;
        b /= 2;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    f0(i, n) {
        cin >> a[i];
    }

    ll ans;
    if(n > 30) {
        ans = 0;
        f0(i, n) {
            ans += (a[i]-1);
        }
    }
    else {
        sort(all(a));
        int r = 1;
        ans = LLONG_MAX;
        while(r < 31623 && pow(1ll*r, 1ll*(n-1)) <= 1.5e14) {
            ll tmp = 0;
            f0(i, n) {
                tmp += abs(a[i] - power(r, i));
            }
            ans = min(ans, tmp);
            ++r;
        }
    }

    cout << ans;
}

int main() {
//    clock_t _clock = clock();
    Im_speed;

    solve();

//    cout << "\n\n" << ((((double) clock()) - ((double)_clock)) / ((double) CLK_TCK));
}


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

#define ar array
#define ff first
#define ss second
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define deb(x) cerr << #x << " = " << x << "\n"
#define f0(i, n) for(int i = 0; i < n; ++i)
#define fo(i, k, n) for(int i = k; i < n; ++i)
#define rf0(n, i) for(int i = n-1; ~i; --i)
#define rfo(n, k, i) for(int i = n-1; i >= k; --i)
#define Im_speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

//ifstream f("date.in");
//ofstream g("date.out");

const int nax = 1e9 + 7;
const int mod = 1e9 + 7;
const int inf = (1 << 30);
const ld PI = 3.1415926535897932384626433832795;

ll power(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b&1) {
            res *= a;
        }
        a *= a;
        b /= 2;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    f0(i, n) {
        cin >> a[i];
    }

    ll ans;
    if(n > 30) {
        ans = 0;
        f0(i, n) {
            ans += (a[i]-1);
        }
    }
    else {
        sort(all(a));
        int r = 1;
        ans = LLONG_MAX;
        while(pow(1ll*r, 1ll*(n-1)) <= 1e11) {
            ll tmp = 0;
            f0(i, n) {
                tmp += abs(a[i] - power(r, i));
            }
            ans = min(ans, tmp);
            ++r;
        }
    }

    cout << ans;
}

int main() {
//    clock_t _clock = clock();
    Im_speed;

    solve();

//    cout << "\n\n" << ((((double) clock()) - ((double)_clock)) / ((double) CLK_TCK));
}


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

#define ar array
#define ff first
#define ss second
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define deb(x) cerr << #x << " = " << x << "\n"
#define f0(i, n) for(int i = 0; i < n; ++i)
#define fo(i, k, n) for(int i = k; i < n; ++i)
#define rf0(n, i) for(int i = n-1; ~i; --i)
#define rfo(n, k, i) for(int i = n-1; i >= k; --i)
#define Im_speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

//ifstream f("date.in");
//ofstream g("date.out");

const int nax = 1e9 + 7;
const int mod = 1e9 + 7;
const int inf = (1 << 30);
const ld PI = 3.1415926535897932384626433832795;

ll power(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b&1) {
            res *= a;
        }
        a *= a;
        b /= 2;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    f0(i, n) {
        cin >> a[i];
    }

    ll ans;
    if(n > 30) {
        ans = 0;
        f0(i, n) {
            ans += (a[i]-1);
        }
    }
    else {
        sort(all(a));
        int r = 1;
        ans = LLONG_MAX;
        while(r < 31624 && pow(1ll*r, 1ll*(n-1)) <= 1e16) {
            ll tmp = 0;
            f0(i, n) {
                tmp += abs(a[i] - power(r, i));
            }
            ans = min(ans, tmp);
            ++r;
        }
    }

    cout << ans;
}

int main() {
//    clock_t _clock = clock();
    Im_speed;

    solve();

//    cout << "\n\n" << ((((double) clock()) - ((double)_clock)) / ((double) CLK_TCK));
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<map>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;
ll a[100005];
ll qpow(ll a,int n)
{
	ll ans=1;
	while(n) {
		if(n&1) ans=(ll)(ans*a);
		a=(ll)a*a;
		n>>=1;
	}
	return ans;
}
ll abs1(ll x)
{
	if(x>0) return x;
	return -x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
	int n;cin>>n;
	ll ans1=0,ans;
	for(int i=1;i<=n;i++)
	cin>>a[i],ans1+=a[i];ans=ans1;
	sort(a+1,a+1+n);
	for(ll i=2;i<=sqrt(ans1)+1;i++)
	{
		ll sum=0;
		for(ll j=1;j<=n;j++)
		sum+=abs1(qpow(i,j-1)-a[j]);
		//cout<<sum<<endl;
		if(ans<sum) {
			break;
		}
		ans=sum;
	}
	cout<<ans<<endl;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
#define int long long
typedef long long ll;

int qpow(int aa,int qq)
{
	int ans=1;
    while(qq>0)
	{
        if(qq%2==0)
		{
            qq=qq/2;
            aa=aa*aa;
        }
		else
		{
            qq=qq-1;
            ans=ans*aa;
            qq=qq/2;
            aa=aa*aa;
        }
    }
    return ans;
}
int gcd(int a,int b)
{
    int r;
    while(b>0)
    {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
ll min1(ll x,ll y)
{
	if(x<y) return x;
	return y;
}
long long a[100005];
long long ans=1e18;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
	int n;long long ans1=0;
	cin>>n;
	bool fl=false;
	for(int i=0;i<n;i++)
	cin>>a[i],ans1+=a[i];
	sort(a,a+n);
	for(int x=1;x<=sqrt(ans1)+1;x++)
	{
		if(fl) break;
		int now=0;
		for(int i=0;i<n;i++)
		{
			now+=abs(a[i]-qpow(x,i));
			if(now>ans)
			{
				fl=true;
				break;
			}
		}
		ans=min1(ans,now);
	}
	cout<<ans<<endl;
	return 0;
}


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

const long long int INF = (long long)1e15;

int N;
int arr[101010];

__int128 abds(__int128 x)
{
    if(x>0) return x;
    return -x;
}

int main()
{
    cin >> N;
    for(int i=0; i<N; ++i)
        cin >> arr[i];
    sort(arr, arr+N);
    __int128 ans = INF;
    int cmax;
    if(N == 3) cmax = (int)1e7;
    else cmax = (int)1e7/N;
    for(int c=1; c<=cmax; ++c)
    {
        __int128 loc = 0;
        __int128 v = 1;
        for(int i=0; i<N; ++i)
        {
            loc += abds(arr[i]-v);

            v *= c;
        }
        if(ans>loc) ans = loc;
    }
    cout << (long long)ans << endl;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<map>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;
ll a[100005];
ll qpow(ll a,ll n)
{
	ll ans=1;
	while(n) {
		if(n&1) ans=(ll)(ans*a);
		a=(ll)a*a;
		n>>=1;
	}
	return ans;
}
ll abs1(ll x)
{
	if(x>0) return x;
	return -x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
	ll n;cin>>n;
	ll ans1=0,ans;
	for(int i=1;i<=n;i++)
	cin>>a[i],ans1+=a[i];
	ans=-1;
	sort(a+1,a+1+n);
	for(ll i=1;i<=sqrt(ans1)+1;i++)
	{
		ll sum=0;
		for(ll j=1;j<=n;j++)
		sum+=abs1(qpow(i,j-1)-a[j]);
		//cout<<sum<<endl;
		if(ans!=-1&&ans<sum) {
			break;
		}
		ans=sum;
	}
	cout<<ans<<endl;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<map>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;
ll a[100005];
ll qpow(ll a,int n)
{
	ll ans=1;
	while(n) {
		if(n&1) ans=(ll)(ans*a);
		a=(ll)a*a;
		n>>=1;
	}
	return ans;
}
ll abs1(ll x)
{
	if(x>0) return x;
	return -x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
	int n;cin>>n;
	ll ans1=0,ans;
	for(int i=1;i<=n;i++)
	cin>>a[i],ans1+=a[i];ans=-1;
	sort(a+1,a+1+n);
	for(ll i=2;i<=sqrt(ans1)+1;i++)
	{
		ll sum=0;
		for(ll j=1;j<=n;j++)
		sum+=abs1(qpow(i,j-1)-a[j]);
		//cout<<sum<<endl;
		if(ans!=-1&&ans<sum) {
			break;
		}
		ans=sum;
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long)1e15;

int N;
int arr[101010];

long long abds(long long x)
{
    if(x>0) return x;
    return -x;
}

int main()
{
    cin >> N;
    for(int i=0; i<N; ++i)
        cin >> arr[i];
    sort(arr, arr+N);
    long long ans = INF;
    int cmax;
    if(N == 3) cmax = (int)1e7;
    else cmax = (int)1e7/N;
    for(int c=1; c<=cmax; ++c)
    {
        long long loc = 0;
        long long v = 1;
        for(int i=0; i<N; ++i)
        {
            loc += abds(arr[i]-v);

            v *= c;
        }
        if(ans>loc) ans = loc;
    }
    cout << (long long)ans << endl;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<map>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;
ll a[100005];
ll qpow(ll a,ll n)
{
	ll ans=1;
	while(n) {
		if(n&1) ans=(ll)(ans*a);
		a=(ll)a*a;
		n>>=1;
	}
	return ans;
}
ll abs1(ll x)
{
	if(x>0) return x;
	return -x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
	ll n;cin>>n;
	ll ans1=0,ans;
	for(int i=1;i<=n;i++)
	cin>>a[i],ans1+=a[i];
	ans=-1;
	sort(a+1,a+1+n);
	for(ll i=1;i<=sqrt(ans1)+1;i++)
	{
		ll sum=0;
		for(ll j=1;j<=n;j++)
		{
			sum+=abs1(qpow(i,j-1)-a[j]);
			if(ans!=-1&&ans<sum) {
				break;
		    }
		}
		//cout<<sum<<endl;
		if(ans!=-1&&ans<sum) {
			break;
		}
		ans=sum;
	}
	cout<<ans<<endl;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<map>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;
ll a[100005];
ll qpow(ll a,int n)
{
	ll ans=1;
	while(n) {
		if(n&1) ans=(ll)(ans*a);
		a=(ll)a*a;
		n>>=1;
	}
	return ans;
}
ll abs1(ll x)
{
	if(x>0) return x;
	return -x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
	int n;cin>>n;
	ll ans1=0,ans;
	for(int i=1;i<=n;i++)
	cin>>a[i],ans1+=a[i];ans=ans1;
	sort(a+1,a+1+n);
	for(ll i=2;i<=sqrt(ans1)+1;i++)
	{
		ll sum=0;
		for(int j=1;j<=n;j++)
		sum+=abs1(qpow(i,j-1)-a[j]);
		//cout<<sum<<endl;
		if(ans<sum) {
			break;
		}
		ans=sum;
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long)1e15;

int N;
int arr[101010];

unsigned long long abds(unsigned long long x)
{
    if(x>0) return x;
    return -x;
}

int main()
{
    cin >> N;
    for(int i=0; i<N; ++i)
        cin >> arr[i];
    sort(arr, arr+N);
    unsigned long long ans = INF;
    int cmax;
    if(N == 3) cmax = (int)1e7;
    else cmax = (int)1e7/N;
    for(int c=1; c<=cmax; ++c)
    {
        unsigned long long loc = 0;
        unsigned long long v = 1;
        for(int i=0; i<N; ++i)
        {
            loc += abds(arr[i]-v);

            v *= c;
        }
        if(ans>loc) ans = loc;
    }
    cout << (unsigned long long)ans << endl;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<map>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;
ll a[100005];
ll qpow(ll a,int n)
{
	ll ans=1;
	while(n) {
		if(n&1) ans=(ll)(ans*a);
		a=a*a;
		n>>=1;
	}
	return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
	int n;cin>>n;
	ll ans1=0,ans;
	for(int i=1;i<=n;i++)
	cin>>a[i],ans1+=a[i];ans=ans1;
	sort(a+1,a+1+n);
	for(int i=2;i<=sqrt(ans1)+1;i++)
	{
		ll sum=0;
		for(int j=1;j<=n;j++)
		sum+=abs(qpow(i,j-1)-a[j]);
		//cout<<sum<<endl;
		if(ans<sum) {
			break;
		}
		ans=sum;
	}
	cout<<ans<<endl;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<map>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;
ll a[100005];
ll qpow(ll a,int n)
{
	ll ans=1;
	while(n) {
		if(n&1) ans=(ll)(ans*a);
		a=a*a;
		n>>=1;
	}
	return ans;
}
ll abs1(ll x)
{
	if(x>0) return x;
	return -x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
	int n;cin>>n;
	ll ans1=0,ans;
	for(int i=1;i<=n;i++)
	cin>>a[i],ans1+=a[i];ans=ans1;
	sort(a+1,a+1+n);
	for(int i=2;i<=sqrt(ans1)+1;i++)
	{
		ll sum=0;
		for(int j=1;j<=n;j++)
		sum+=abs1(qpow(i,j-1)-a[j]);
		//cout<<sum<<endl;
		if(ans<sum) {
			break;
		}
		ans=sum;
	}
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
int qpow(int base,int power)
{
	int result=1;
    while(power>0)
	{
        if(power%2==0)
		{
            power=power/2;
            base=base*base;
        }
		else
		{
            power=power-1;
            result=result*base;
            power=power/2;
            base=base*base;
        }
    }
    return result;
}
int _min(int xx,int zz)
{
	if(xx<zz)
		return xx;
	return zz;
}
int T,a[111111];
int ans=1e19,flag=0;
signed main()
{
	cin>>T;
	for(int i=0;i<T;++i)
		cin>>a[i];
	sort(a,a+T);
	for(int x=1;x<=1e19;++x)
	{
		if(flag)
			break;
		int now=0;
		for(int i=0;i<T;++i)
		{
			now+=abs(a[i]-(qpow(x,i)));
			if(now>ans)
			{
				flag=1;
				break;
			}
		}
		ans=_min(ans,now);
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 9.0e18;
        ll c;
        for(int i = 0; i < n; i++){
            res += llabs(arr[i] - 1);
        }
        if(n > 50){
        for(ll j = 1;; j++){
            ll ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){  ans += llabs(cnt - arr[i]);cnt *= j;
            }
            if(ans > 1e13) break;
            res = min(res,ans);
        }
        }
        cout<<res<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        if(n < 35){
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 1e18;
        ll c;
        for(ll j = max(1ll,x-1000); j <= x + 10; j++){
            ll ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){  ans += abs(cnt - arr[i]);cnt *= j;
            }
            if(res >= ans && ans > 0 ) {
                res = ans;
                c = j;
            }
        }
        printf("%lld\n",res);}

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 9.0e18;
        ll c;
        for(ll j = 1;j <= x+1; j++){
            ll ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){  ans += abs(cnt - arr[i]);cnt *= j;
            }
            if(res >= ans && ans > 0 ) {
                res = ans;
                c = j;
            }
        }
        cout<<res<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 0;
        ll c;
        for(int i = 0; i < n; i++){
            res += llabs(arr[i] - 1);
        }
        if(n < 50){
            res = 9e18;
        for(ll j = 1;; j++){
            ll ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){  ans += llabs(cnt - arr[i]);cnt *= j;
            }
            if(ans > 1e13) break;
            res = min(res,ans);
        }
        }
        cout<<res<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 9.0e18;
        ll c;
        for(ll j = 1;; j++){
            ll ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){  ans += abs(cnt - arr[i]);cnt *= j;
            }
            if(ans > 1e13) break;
            if(res >= ans && ans > 0 ) {
                res = ans;
                c = j;
            }
        }
        cout<<res<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 9.0e18;
        ll c;
        for(ll j = 1;; j++){
            ll ans = 0,cnt = 1;

            for(int i = 0; i < n; i++ ){
                ans += abs(cnt - arr[i]);
            cnt *= j;
            }
            if(ans > 1e13) break;
            if(res >= ans && ans > 0 ) {
                res = ans;
                c = j;
            }
        }
        cout<<res<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 1e18;
        ll c;
        for(ll j = max(1ll,x-10); j <= x + 10; j++){
            ll ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){
                ans += abs(cnt - arr[i]);
                cnt *= j;
            }
            if(res >= ans) {
                res = ans;
                c = j;
            }
        }
        printf("%lld\n",res);

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        if(n < 35){
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 1e18;
        ll c;
        for(ll j = max(1ll,x-100); j <= x + 100; j++){
            ll ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){
                ans += abs(cnt - arr[i]);
                cnt *= j;
            }
            if(res >= ans) {
                res = ans;
                c = j;
            }
        }
        printf("%lld\n",res);}
        else{
            ll ans = 0;
            for(int i = 0; i < n; i++){
                ans += abs(arr[i] - 1);
            }
            printf("%lld\n",ans);
        }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 1e18;
        ll c;
        for(ll j = max(1ll,x-1000); ; j++){
            ll ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){  ans += abs(cnt - arr[i]);cnt *= j;
            }
            if(res >= ans && ans > 0 ) {
                res = ans;
                c = j;
            }
            if(j > x && ans > res ) break;
        }
        printf("%lld\n",res);

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 9.0e18;
        ll c;
        for(int i = 0; i < n; i++){
            res += llabs(arr[i] - 1);
        }
        if(n < 50){
        for(ll j = 1;; j++){
            ll ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){  ans += llabs(cnt - arr[i]);cnt *= j;
            }
            if(ans > 1e13) break;
            res = min(res,ans);
        }
        }
        cout<<res<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 9.0e18;
        ll c;
        for(ll j = 1;j <= 31623; j++){
            ll ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){  ans += abs(cnt - arr[i]);cnt *= j;
            }
            if(ans < 0) break;
            if(res >= ans && ans > 0 ) {
                res = ans;
                c = j;
            }
        }
        cout<<res<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 9.0e18;
        ll c;
        for(ll j = max(1ll,x-1000);j < x + 1000; j++){
            ll ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){  ans += abs(cnt - arr[i]);cnt *= j;
            }
            if(ans < 0) break;
            if(res >= ans && ans > 0 ) {
                res = ans;
                c = j;
            }
        }
        printf("%lld\n",res);

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        __int64 res = 9.0e18;
        ll c;
        for(ll j = max(1ll,x-1000);j < x + 1000; j++){
            __int64 ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){  ans += abs(cnt - arr[i]);cnt *= j;
            }
            if(ans < 0) break;
            if(res >= ans && ans > 0 ) {
                res = ans;
                c = j;
            }
        }
        cout<<res<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x)
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
ll arr[N];
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int n = read<int>();
        for(int i = 0; i < n; i++){
            arr[i] = read<ll>();
        }
        sort(arr,arr+n);
        double y = 1.0/(n-1);
        ll x = arr[n-1];
        x = pow(x,y);
        ll res = 9.0e18;
        ll c;
        for(ll j = 1;j <= 31630; j++){
            ll ans = 0,cnt = 1;
            for(int i = 0; i < n; i++ ){  ans += abs(cnt - arr[i]);cnt *= j;if(cnt < 0) break;
            }
            if(cnt < 0) break;
            if(res >= ans && ans > 0 ) {
                res = ans;
                c = j;
            }
        }
        cout<<res<<endl;

}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		if (n == 1)
		{
			cout << v[0] - 1 << "\n";
		}
		else if (n == 2)
		{
			cout << 0 << "\n";
		}
		else
		{
			ll maxno = 1;
			for (; pow(maxno, n - 1) <= INT_MAX; maxno++);
			for (ll i = 1; i <= maxno + 5; i++)
			{
				ll tcost = 0;
				for (ll j = 0; j < n; j++)
				{
					ll temp = pow(i, j);
					tcost += llabs(v[j] - temp);
				}
				cost = std::min(cost, tcost);
			}
			cout << cost << "\n";
		}
	}
	return 0;
}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		if (n <= 2)
		{
			cout << v[0] - 1 << "\n";
		}
		else
		{
			// ll lim = pow(1e18, 1.0 / n);
			bool flag = true;
			for (ll i = 1; flag; i++)
			{
				ll tcost = 0;
				for (ll j = 0; j < n; j++)
				{
					ll temp = power(i, j);
					if (temp > 10e9)
					{
						flag = false;
						break;
					}
					tcost += llabs(v[j] - temp);
				}
				cost = std::min(cost, tcost);
			}
			cout << cost << "\n";
		}
	}
	return 0;
}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll min = LLONG_MAX, max = LLONG_MIN;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
			min = std::min(v[i], min);
			max = std::max(v[i], max);
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		ll maxno = 1;
		for (; pow(maxno, n - 1) <= max; maxno++);

		for (int i = 1; i <= maxno; i++)
		{
			ll tcost = 0;
			for (int j = 0; j < n; j++)
			{
				ll temp = pow(i, j);
				tcost += llabs(v[j] - temp);
			}
			cost = std::min(cost, tcost);
		}
		cout << cost << "\n";
	}
	return 0;
}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		if (n == 1)
		{
			cout << v[0] - 1 << "\n";
		}
		else if (n == 2)
		{
			cout << 0 << "\n";
		}
		else
		{
			for (ll i = 1; power(i, n - 1) <= 100000000000; i++)
			{
				ll tcost = 0;
				for (ll j = 0; j < n; j++)
				{
					ll temp = power(i, j);
					tcost += llabs(v[j] - temp);
				}
				cost = std::min(cost, tcost);
			}
			cout << cost << "\n";
		}
	}
	return 0;
}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		if (n <= 2)
		{
			cout << v[0] - 1 << "\n";
		}
		else
		{
			// ll lim = pow(1e18, 1.0 / n);
			bool flag = true;
			for (ll i = 1; flag; i++)
			{
				ll val = 1;
				ll tcost = 0;
				for (ll j = 0; j < n; j++)
				{
					if (val > 10e10)
					{
						flag = false;
						break;
					}
					tcost += llabs(v[j] - val);
					val = val * i;
				}
				if(flag) cost = std::min(cost, tcost);
			}
			cout << cost << "\n";
		}
	}
	return 0;
}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll min = LLONG_MAX, max = LLONG_MIN;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
			min = std::min(v[i], min);
			max = std::max(v[i], max);
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		ll maxno = 1;
		for (; pow(maxno, n - 1) <= max; maxno++);

		for (int i = 1; i <= maxno + 5; i++)
		{
			ll tcost = 0;
			for (int j = 0; j < n; j++)
			{
				ll temp = pow(i, j);
				tcost += llabs(v[j] - temp);
			}
			cost = std::min(cost, tcost);
		}
		cout << cost << "\n";
	}
	return 0;
}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		if (n <= 2)
		{
			cout << v[0] - 1 << "\n";
		}
		else
		{
			// ll lim = pow(1e18, 1.0 / n);
			bool flag = true;
			for (ll i = 1; flag; i++)
			{
				ll tcost = 0;
				for (ll j = 0; j < n; j++)
				{
					ll temp = power(i, j);
					if (temp > 10e17)
					{
						flag = false;
						break;
					}
					tcost += llabs(v[j] - temp);
				}
				cost = std::min(cost, tcost);
			}
			cout << cost << "\n";
		}
	}
	return 0;
}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		if (n <= 2)
		{
			cout << v[0] - 1 << "\n";
		}
		else
		{
			// ll lim = pow(1e18, 1.0 / n);
			bool flag = true;
			for (ll i = 1; flag; i++)
			{
				ll tcost = 0;
				for (ll j = 0; j < n; j++)
				{
					ll temp = power(i, j);
					if (temp > 10e10)
					{
						flag = false;
						break;
					}
					tcost += llabs(v[j] - temp);
				}
				cost = std::min(cost, tcost);
			}
			cout << cost << "\n";
		}
	}
	return 0;
}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll max = LLONG_MIN;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
			max = std::max(v[i], max);
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		ll maxno = 1;
		for (; pow(maxno, n - 1) <= INT_MAX; maxno++);

		for (int i = 1; i <= maxno + 5; i++)
		{
			ll tcost = 0;
			for (int j = 0; j < n; j++)
			{
				ll temp = pow(i, j);
				tcost += llabs(v[j] - temp);
			}
			cost = std::min(cost, tcost);
		}
		cout << cost << "\n";
	}
	return 0;
}


    // Code by Prateek Mishra IIT2018199, IIIT Allahabad.

    /*Input Format:

    */

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

    #define eb emplace_back
    #define fi first
    #define se second
    #define ll long long
    #define ull unsigned long long
    #define mp make_pair
    #define MOD 1000000007
    #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

    ll power(ll x, ll y)
    {
    	ll res = 1;
    	while (y > 0)
    	{
    		if (y & 1) res = res * x;
    		y = y >> 1;
    		x = x * x;
    	}
    	return res;
    }

    int main()
    {
    	FastIO
    	int t = 1;
    	// cin >> t;
    	while (t--)
    	{
    		ll n;
    		cin >> n;
    		std::vector<ll> v(n);
    		for (int i = 0; i < n; i++)
    		{
    			cin >> v[i];
    		}
    		ll cost = LLONG_MAX;
    		sort(v.begin(), v.end());
    		if (n <= 2)
    		{
    			cout << v[0] - 1 << "\n";
    		}
    		else
    		{
    			ll lim = pow(1e18, 1.0 / n);
    			for (ll i = 1; i <= lim; i++)
    			{
    				ll tcost = 0;
    				for (ll j = 0; j < n; j++)
    				{
    					ll temp = power(i, j);
    					tcost += llabs(v[j] - temp);
    				}
    				cost = std::min(cost, tcost);
    			}
    			cout << cost << "\n";
    		}
    	}
    	return 0;
    }


    // Code by Prateek Mishra IIT2018199, IIIT Allahabad.

    /*Input Format:

    */

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

    #define eb emplace_back
    #define fi first
    #define se second
    #define ll long long
    #define ull unsigned long long
    #define mp make_pair
    #define MOD 1000000007
    #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

    ll power(ll x, ll y)
    {
    	ll res = 1;
    	while (y > 0)
    	{
    		if (y & 1) res = res * x;
    		y = y >> 1;
    		x = x * x;
    	}
    	return res;
    }

    int main()
    {
    	FastIO
    	int t = 1;
    	// cin >> t;
    	while (t--)
    	{
    		ll n;
    		cin >> n;
    		std::vector<ll> v(n);
    		for (int i = 0; i < n; i++)
    		{
    			cin >> v[i];
    		}
    		ll cost = LLONG_MAX;
    		sort(v.begin(), v.end());
    		if (n <= 2)
    		{
    			cout << v[0] - 1 << "\n";
    		}
    		else
    		{
    			for (ll i = 1; power(i, n - 1) <= 100000000000; i++)
    			{
    				ll tcost = 0;
    				for (ll j = 0; j < n; j++)
    				{
    					ll temp = power(i, j);
    					tcost += llabs(v[j] - temp);
    				}
    				cost = std::min(cost, tcost);
    			}
    			cout << cost << "\n";
    		}
    	}
    	return 0;
    }


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		if (n <= 2)
		{
			cout << v[0] - 1 << "\n";
		}
		else
		{
			bool flag = true;
			for (ll i = 1; flag; i++)
			{
				ll val = 1;
				ll tcost = 0;
				for (ll j = 0; j < n; j++)
				{
					if (val > 10e9)
					{
						flag = false;
						break;
					}
					tcost += llabs(v[j] - val);
					val = val * i;
				}
				if(flag) cost = std::min(cost, tcost);
			}
			cout << cost << "\n";
		}
	}
	return 0;
}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll min = LLONG_MAX, max = LLONG_MIN;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
			min = std::min(v[i], min);
			max = std::max(v[i], max);
		}
		ll cost = LLONG_MAX;
		ll i = 1;
		for (; pow(i, n - 1) <= max; i++);
		i--;
		// cout<<"i : "<<i<<"\n";
		sort(v.begin(), v.end());
		ll tcost = 0;
		for (int j = 0; j < n; j++)
		{
			ll temp = pow(i, j);
			tcost += llabs(v[j] - temp);
		}
		// cout<<"tcost : "<<tcost<<"\n";
		cost = std::min(cost, tcost);
		i++;
		tcost = 0;
		for (int j = 0; j < n; j++)
		{
			ll temp = pow(i, j);
			tcost += llabs(v[j] - temp);
		}
		cost = std::min(cost, tcost);
		cout<<cost<<"\n";
	}
	return 0;
}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		if (n <= 2)
		{
			cout << v[0] - 1 << "\n";
		}
		else
		{
			// ll lim = pow(1e18, 1.0 / n);
			bool flag = true;
			for (ll i = 1; flag; i++)
			{
				long long val = 1;
				ll tcost = 0;
				for (ll j = 0; j < n; j++)
				{
					if (val > 10e9)
					{
						flag = false;
						break;
					}
					tcost += llabs(v[j] - val);
					val = val * i;
				}
				cost = std::min(cost, tcost);
			}
			cout << cost << "\n";
		}
	}
	return 0;
}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		if (n <= 2)
		{
			cout << v[0] - 1 << "\n";
		}
		else
		{
			// ll lim = pow(1e18, 1.0 / n);
			bool flag = true;
			for (ll i = 1; flag; i++)
			{
				ll tcost = 0;
				for (ll j = 0; j < n; j++)
				{
					ll temp = power(i, j);
					if (temp > 10e15)
					{
						flag = false;
						break;
					}
					tcost += llabs(v[j] - temp);
				}
				cost = std::min(cost, tcost);
			}
			cout << cost << "\n";
		}
	}
	return 0;
}


// Code by Prateek Mishra IIT2018199, IIIT Allahabad.

/*Input Format:

*/

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

#define eb emplace_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1) res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
}

int main()
{
	FastIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		std::vector<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		ll cost = LLONG_MAX;
		sort(v.begin(), v.end());
		if (n <= 2)
		{
			cout << v[0] - 1 << "\n";
		}
		else
		{
			// ll lim = pow(1e18, 1.0 / n);
			bool flag = true;
			for (ll i = 1; flag; i++)
			{
				long long val = 1;
				ll tcost = 0;
				for (ll j = 0; j < n; j++)
				{
					if (val > 10e15)
					{
						flag = false;
						break;
					}
					tcost += llabs(v[j] - val);
					val = val * i;
				}
				cost = std::min(cost, tcost);
			}
			cout << cost << "\n";
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define inf 1e15
using namespace std;
int main()
{
	ll t,n,a[100005];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int u;
	for(int i=1;i<=31623;i++)
	{
		if(pow(i,n-1)>=a[n-1])
		{
			u=i;
			break;
		}
	}
	ll sum1=0,sum2=0,sum1f=0,sum2f=0;
	if(u>1)
	{
		int v=u-1;
		for(int i=0;i<n;i++)
		{
			sum1+=abs(a[i]-pow(u,i));
			if(sum1>=inf) //考虑到可能会特别大成为一个负数，就会影响后面的 min(sum1,sum2) ，因加一个判断条件，是负数的话就不会输出
			{
				sum1f=1;
			}
			sum2+=abs(a[i]-pow(v,i));
			if(sum2>=inf) //同上
			{
				sum2f=1;
			}
		}
		if(sum1f==1) //只要有一方出现了负数，那就输出另一方即可
			cout<<sum2<<endl;
		else if(sum2f==1)
			cout<<sum1<<endl;
		else
			cout<<min(sum1,sum2)<<endl;
	}
	else
	{
		for(int i=0;i<n;i++)
		{
			sum1+=abs(a[i]-pow(u,i));
		}
		cout<<sum1<<endl;
	}

}


#include<bits/stdc++.h>
#define ll long long
#define inf 1e15
using namespace std;
int main()
{
	ll t,n,a[100005];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int u;
	for(int i=1;i<=31623;i++)
	{
		if(pow(i,n-1)>=a[n-1])
		{
			u=i;
			break;
		}
	}
	cout<<u<<endl;
	ll sum1=0,sum2=0,sum1f=0,sum2f=0;
	if(u>1)
	{
		int v=u-1;
		for(int i=0;i<n;i++)
		{
			sum1+=abs(a[i]-pow(u,i));
			if(sum1>=inf) //考虑到可能会特别大成为一个负数，就会影响后面的 min(sum1,sum2) ，因加一个判断条件，是负数的话就不会输出
			{
				sum1f=1;
			}
			sum2+=abs(a[i]-pow(v,i));
			if(sum2>=inf) //同上
			{
				sum2f=1;
			}
		}
		cout<<sum1<<" "<<sum2<<endl;
		if(sum1f==1) //只要有一方出现了负数，那就输出另一方即可
			cout<<sum2<<endl;
		else if(sum2f==1)
			cout<<sum1<<endl;
		else
			cout<<min(sum1,sum2)<<endl;
	}
	else
	{
		for(int i=0;i<n;i++)
		{
			sum1+=abs(a[i]-pow(u,i));
		}
		cout<<sum1<<endl;
}

}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define inf 1e15
using namespace std;
typedef long long ll;
ll mpow(ll a,ll b)
{
	ll ans1=1;
	while(b)
	{
		if(b&1) ans1=ans1*a;
		a=a*a;
		b=b/2;
	}
	if(a==0) return 0;
	else return ans1;
}
int main()
{
	ll n;
	ll mp[100005];
	cin>>n;
	ll  ans=0;
	for(ll i=0;i<n;i++)
	{cin>>mp[i];
	ans+=abs(mp[i]-1);
	}
	sort(mp,mp+n);
	int u;
	//ll ans=inf;
	if(n<=62)
	for(ll i=1;i<=1e6;i++)
	{
		if(mpow(i,n-1)>=inf||mpow(i,n-1)<0)
		{

			break;
		}
		ll cnt=abs(mp[0]-1);
		for(ll j=1;j<n;j++)
		{
			cnt+=abs(mp[j]-mpow(i,j));
		}
		if(cnt<=inf)
		ans=min(ans,cnt);
	}
   cout<<ans<<endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define inf 1e15
using namespace std;
typedef long long ll;
ll mpow(ll a,ll b)
{
	ll ans1=1;
	while(b)
	{
		if(b&1) ans1=ans1*a;
		a=a*a;
		b=b/2;
	}
	if(a==0) return 0;
	else return ans1;
}
int main()
{
	ll n;
	ll mp[100005];
	cin>>n;
	ll  ans=0;
	for(ll i=0;i<n;i++)
	{cin>>mp[i];
	ans+=abs(mp[i]-1);
	}
	sort(mp,mp+n);
	int u;
	//ll ans=inf;
//	if(n<=62)
	for(ll i=1;i<=1e6;i++)
	{
		if(mpow(i,n-1)>=inf||mpow(i,n-1)<0)
		{

			break;
		}
		ll cnt=abs(mp[0]-1);
        int f=0;
		for(ll j=1;j<n;j++)
		{
			cnt+=abs(mp[j]-mpow(i,j));
			if(cnt>=inf) f=1;
		}
		if(f==0)
		ans=min(ans,cnt);
	}
   cout<<ans<<endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define inf 1e15
using namespace std;
typedef long long ll;
ll mpow(ll a,ll b)
{
	ll ans=0;
	while(b)
	{
		if(b&1) ans+=a;
		a=a*a;
		b=b/2;
	}
	return ans;
}
int main()
{
	ll n;
	ll mp[100005];
	cin>>n;
	for(int i=0;i<n;i++) cin>>mp[i];
	sort(mp,mp+n);
	int u;
	for(int i=1;i<=31623;i++)
	{
		if(mpow(i,n-1)>=mp[n-1])
		{
			u=i;
			break;
		}
	}
	if(u>1)
	{
		int v=u-1;
		ll sum1=0,sum2=0;
		ll sum1f=0,sum2f=0;
		sum1=sum1+fabs(mp[0]-1);
		sum2=sum2+fabs(mp[0]-1);
		for(int i=1;i<n;i++)
		{
			sum1=sum1+fabs(mp[i]-mpow(u,i));
			if(sum1>=inf)
			{
				sum1f=1;
			}
			sum2=sum2+fabs(mp[i]-mpow(v,i));
			if(sum2>=inf)
			{
				sum2f=1;
			}

		}
		if(sum1f==1) cout<<sum2<<endl;
		else if(sum2f==1) cout<<sum1<<endl;
		else cout<<min(sum1,sum2)<<endl;
	}
	else
	{
		ll sum=fabs(mp[0]-1);
		for(int i=1;i<n;i++)
		{
			sum=sum+fabs(mp[i]-mpow(u,i));
		}
		cout<<sum<<endl;
	}
	return 0;

}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
const ll inf=1e15;
int main()
{
	ll n;
	ll mp[100005];
	cin>>n;
	for(int i=0;i<n;i++) cin>>mp[i];
	sort(mp,mp+n);
	int u;
	for(int i=1;i<=31623;i++)
	{
		if(pow(i,n-1)>=mp[n-1])
		{
			u=i;
			break;
		}
	}
	if(u>1)
	{
		int v=u-1;
		ll sum1=0,sum2=0;
		ll sum1f=0,sum2f=0;
		for(int i=0;i<n;i++)
		{
			sum1=sum1+fabs(mp[i]-pow(u,i));
			if(sum1>=inf)
			{
				sum1f=1;
			}
			sum2=sum2+fabs(mp[i]-pow(v,i));
			if(sum2>=inf)
			{
				sum2f=1;
			}

		}
		if(sum1f==1) cout<<sum2<<endl;
		else if(sum2f==1) cout<<sum1<<endl;
		else cout<<min(sum1,sum2)<<endl;
	}
	else
	{
		ll sum=0;
		for(int i=0;i<n;i++)
		{
			sum=sum+fabs(mp[i]-pow(u,i));
		}
		cout<<sum<<endl;
	}
	return 0;

}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define inf 1e15
using namespace std;
typedef long long ll;
int mpow(int a,int b)
{
	int ans1=1;
	while(b)
	{
		if(b&1) ans1=ans1*a;
		a=a*a;
		b=b/2;
	}
	if(a==0) return 0;
	else return ans1;
}
int main()
{
	ll n;
	ll mp[100005];
	cin>>n;
	for(int i=0;i<n;i++) cin>>mp[i];
	sort(mp,mp+n);
	int u;
	ll ans=inf;
	for(int i=1;i<=1e6;i++)
	{
		if(mpow(i,n-1)>=inf||mpow(i,n-1)<0)
		{

			break;
		}
		ll cnt=fabs(mp[0]-1);
		for(int j=1;j<n;j++)
		{
			cnt+=fabs(mp[j]-mpow(i,j));
		}
		ans=min(ans,cnt);
	}
   cout<<ans<<endl;
	return 0;

}


#include<bits/stdc++.h>
#define ll long long
#define inf 1e15
using namespace std;
int main()
{
	ll t,n,a[100005];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int u;
	for(int i=1;i<=31623;i++)
	{
		if(pow(i,n-1)>=a[n-1])
		{
			u=i;
			break;
		}
	}
//	cout<<u<<endl;
	ll sum1=0,sum2=0,sum1f=0,sum2f=0;
	if(u>1)
	{
		int v=u-1;
		for(int i=0;i<n;i++)
		{
			sum1+=abs(a[i]-pow(u,i));
			if(sum1>=inf) //考虑到可能会特别大成为一个负数，就会影响后面的 min(sum1,sum2) ，因加一个判断条件，是负数的话就不会输出
			{
				sum1f=1;
			}
			sum2+=abs(a[i]-pow(v,i));
			if(sum2>=inf) //同上
			{
				sum2f=1;
			}
		}
		//cout<<sum1<<" "<<sum2<<endl;
		if(sum1f==1) //只要有一方出现了负数，那就输出另一方即可
			cout<<sum2<<endl;
		else if(sum2f==1)
			cout<<sum1<<endl;
		else
			cout<<min(sum1,sum2)<<endl;
	}
	else
	{
		for(int i=0;i<n;i++)
		{
			sum1+=abs(a[i]-pow(u,i));
		}
		cout<<sum1<<endl;
}

}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define inf 1e15;
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	ll mp[100005];
	cin>>n;
	for(int i=0;i<n;i++) cin>>mp[i];
	sort(mp,mp+n);
	int u;
	for(int i=1;i<=31623;i++)
	{
		if(pow(i,n-1)>=mp[n-1])
		{
			u=i;
			break;
		}
	}
	if(u>1)
	{
		int v=u-1;
		ll sum1=0,sum2=0;
		ll sum1f=0,sum2f=0;
		for(int i=0;i<n;i++)
		{
			sum1=sum1+fabs(mp[i]-pow(u,i));
			if(sum1>=inf)
			{
				sum1f=1;
			}
			sum2=sum2+fabs(mp[i]-pow(v,i));
			if(sum2>=inf)
			{
				sum2f=1;
			}

		}
		if(sum1f==1) cout<<sum2<<endl;
		else if(sum2f==1) cout<<sum1<<endl;
		else cout<<min(sum1,sum2)<<endl;
	}
	else
	{
		ll sum=0;
		for(int i=0;i<n;i++)
		{
			sum=sum+fabs(mp[i]-pow(u,i));
		}
		cout<<sum<<endl;
	}
	return 0;

}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define inf 1e15
using namespace std;
typedef long long ll;
int mpow(int a,int b)
{
	int ans1=1;
	while(b)
	{
		if(b&1) ans1=ans1*a;
		a=a*a;
		b=b/2;
	}
	if(a==0) return 0;
	else return ans1;
}
int main()
{
	ll n;
	ll mp[100005];
	cin>>n;
	ll  ans=0;
	for(int i=0;i<n;i++)
	{cin>>mp[i];
	ans+=fabs(mp[i]-1);
	}
	sort(mp,mp+n);
	int u;
	//ll ans=inf;
	for(int i=1;i<=1e6;i++)
	{
		if(mpow(i,n-1)>=inf||mpow(i,n-1)<0)
		{

			break;
		}
		ll cnt=fabs(mp[0]-1);
		for(int j=1;j<n;j++)
		{
			cnt+=fabs(mp[j]-mpow(i,j));
		}
		ans=min(ans,cnt);
	}
   cout<<ans<<endl;
	return 0;

}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <cctype>
using namespace std;
typedef long long ll;
typedef vector<int> veci;
typedef vector<ll> vecl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T>
inline void read(T &ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return ;
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1:1;
    ret = (c == '-') ? 0:(c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return ;
}
inline void outi(int x) {if (x > 9) outi(x / 10);putchar(x % 10 + '0');}
inline void outl(ll x) {if (x > 9) outl(x / 10);putchar(x % 10 + '0');}
const int maxn = 1e5 + 10;
ll a[maxn] = {0};
ll inf = 1e15;
int main() {
    int n; read(n);
    for (int i = 1; i <= n; i++) read(a[i]);
    sort(a + 1, a + n + 1);
    ll ans = inf;
    for (int i = 1; i <= sqrt(inf); i++) {
        if (pow(i, n) > inf) break;
        ll cnt = 0;
        for (int j = 1; j <= n; j++) {
            cnt += abs(pow(i, j - 1) - a[j]);
        }
        ans = min(ans, cnt);
    }
    printf("%lld\n", ans);
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define inf 1e15
using namespace std;
typedef long long ll;
ll mpow(ll a,ll b)
{
	ll ans1=1;
	while(b)
	{
		if(b&1) ans1=ans1*a;
		a=a*a;
		b=b/2;
	}
	if(a==0) return 0;
	else return ans1;
}
int main()
{
	ll n;
	ll mp[100005];
	cin>>n;
	ll  ans=0;
	for(ll i=0;i<n;i++)
	{cin>>mp[i];
	ans+=abs(mp[i]-1);
	}
	sort(mp,mp+n);
	int u;
	//ll ans=inf;
//	if(n<=62)
	for(ll i=1;i<=1e6;i++)
	{
		if(mpow(i,n-1)>=inf||mpow(i,n-1)<0)
		{

			break;
		}
		ll cnt=abs(mp[0]-1);
		for(ll j=1;j<n;j++)
		{
			cnt+=abs(mp[j]-mpow(i,j));
		}
		if(cnt<=inf&&cnt>=0)
		ans=min(ans,cnt);
	}
   cout<<ans<<endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define inf 1e15
using namespace std;
typedef long long ll;
ll mpow(ll a,ll b)
{
	ll ans1=1;
	while(b)
	{
		if(b&1) ans1=ans1*a;
		a=a*a;
		b=b/2;
	}
	if(a==0) return 0;
	else return ans1;
}
int main()
{
	ll n;
	ll mp[100005];
	cin>>n;
	ll  ans=0;
	for(ll i=0;i<n;i++)
	{cin>>mp[i];
	ans+=abs(mp[i]-1);
	}
	sort(mp,mp+n);
	int u;
	//ll ans=inf;
	for(ll i=1;i<=1e6;i++)
	{
		if(mpow(i,n-1)>=inf||mpow(i,n-1)<0)
		{

			break;
		}
		ll cnt=abs(mp[0]-1);
		for(ll j=1;j<n;j++)
		{
			cnt+=abs(mp[j]-mpow(i,j));
		}
		ans=min(ans,cnt);
	}
   cout<<ans<<endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define inf 1e15
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	ll mp[100005];
	cin>>n;
	for(int i=0;i<n;i++) cin>>mp[i];
	sort(mp,mp+n);
	int u;
	ll ans=inf;
	for(int i=1;i<=31623;i++)
	{
		if(pow(i,n-1)>inf)
		{

			break;
		}
		ll cnt=0;
		for(int j=0;j<n;j++)
		{
			cnt=cnt+fabs(pow(i,j)-mp[j]);
		}
		 ans=min(ans,cnt);

	}
	cout<<ans<<endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define inf 1e15
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	ll mp[100005];
	cin>>n;
	for(int i=0;i<n;i++) cin>>mp[i];
	sort(mp,mp+n);
	int u;
	for(int i=1;i<=31623;i++)
	{
		if(pow(i,n-1)>=mp[n-1])
		{
			u=i;
			break;
		}
	}
	if(u>1)
	{
		int v=u-1;
		ll sum1=0,sum2=0;
		ll sum1f=0,sum2f=0;
		for(int i=0;i<n;i++)
		{
			sum1=sum1+fabs(mp[i]-pow(u,i));
			if(sum1>=inf)
			{
				sum1f=1;
			}
			sum2=sum2+fabs(mp[i]-pow(v,i));
			if(sum2>=inf)
			{
				sum2f=1;
			}

		}
		if(sum1f==1) cout<<sum2<<endl;
		else if(sum2f==1) cout<<sum1<<endl;
		else cout<<min(sum1,sum2)<<endl;
	}
	else
	{
		ll sum=0;
		for(int i=0;i<n;i++)
		{
			sum=sum+fabs(mp[i]-pow(u,i));
		}
		cout<<sum<<endl;
	}
	return 0;

}


#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <algorithm>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn=1e6+5;
int a[maxn];

int qmi(int a,int k) {
	int ans=1;
	while(k) {
		if(k&1)ans=ans*a;
		k>>=1;
		a=a*a;
		//cout<<k<<endl;
	}
	if(a==0)return 0;
	else return ans;
}
main() {
	IOS;
	int n;
	cin>>n;
	int ans=0;
	for(int i=0; i<n; i++) {
		cin>>a[i];
		ans+=abs(a[i]-1);
	}
	sort(a,a+n);
	int maxx=0;
	if(n<=62)for(int i=1; i<=1e6; i++) {
			if(qmi(i,n-1)>=1e15||qmi(i,n-1)<0)break;
			maxx=abs(a[0]-1);
			for(int j=1; j<n; j++) {
				maxx+=abs(a[j]-qmi(i,j));
			}
			ans=min(ans,maxx);
		}
	cout<<ans<<endl;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define inf 1e15
using namespace std;
typedef long long ll;
ll mpow(ll a,ll b)
{
	ll ans1=1;
	while(b)
	{
		if(b&1) ans1=ans1*a;
		a=a*a;
		b=b/2;
	}
	if(a==0) return 0;
	else return ans1;
}
int main()
{
	ll n;
	ll mp[100005];
	cin>>n;
	ll  ans=0;
	for(ll i=0;i<n;i++)
	{cin>>mp[i];
	ans+=abs(mp[i]-1);
	}
	sort(mp,mp+n);
	int u;
	//ll ans=inf;
	for(ll i=1;i<=1e6;i++)
	{
		if(mpow(i,n-1)>=inf||mpow(i,n-1)<0)
		{

			break;
		}
		ll cnt=abs(mp[0]-1);
		for(ll j=1;j<n;j++)
		{
			cnt+=abs(mp[j]-mpow(i,j));
		}
		if(cnt<=inf)
		ans=min(ans,cnt);
	}
   cout<<ans<<endl;
	return 0;

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace std;

using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

//*s.find_by_order(1)
//s.order_of_key( 1 ) ;

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )
#define      pii     pair < int , int >

//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//

const ll Max =  1e10 ;
const int SIZE =  1e18  ;

int main () {

    FASTIO ;

    int n ;
    cin >> n ;

    vector < ll > v( n ) ;

    for( int i = 0 ; i < n ; i++ )
        cin >> v[ i ] ;

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

    if( n == 2 )
        cout << v[ 0 ] - 1 << endl ;
    else {

        ll ans = SIZE ;

        for( int i = 2 ; i <= 1000000 ; i++ ) {

            ll k = 1 , x = 0 , f = 0 ;

            for( int j = 0 ; j < n ; j++ ) {

                x += abs( v[ j ] - k ) ;

                if( x > ans ){
                    f = 1 ;
                    break ;
                }

                if( j == n - 1 ) break ;

                k *= i ;

                if( k >= Max ) {
                    f = 1 ;
                    break ;
                }
            }

            if( !f ) ans = min( ans , x ) ;
        }

        cout << ans << endl ;
    }

    return  0 ;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace std;

using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

//*s.find_by_order(1)
//s.order_of_key( 1 ) ;

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )
#define      pii     pair < int , int >

//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//

const ll Max =  1e10 ;
const int SIZE =  1e18  ;

int main () {

    FASTIO ;

    int n ;
    cin >> n ;

    vector < ll > v( n ) ;

    for( int i = 0 ; i < n ; i++ )
        cin >> v[ i ] ;

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

    ll ans = SIZE ;

    for( int i = 2 ; i <= 1000000 ; i++ ) {

        ll k = 1, x = 0, f = 0 ;

        for( int j = 0 ; j < n ; j++ ) {

            x += abs( v[ j ] - k ) ;

            if( x > ans ) {
                f = 1 ;
                break ;
            }

            if( j == n - 1 )
                break ;

            k *= i ;

         /*   if( k >= Max ) {
                f = 1 ;
                break ;
            }*/
        }

        if( !f )
            ans = min( ans, x ) ;
    }

    cout << ans << endl ;

    return  0 ;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace std;

using namespace __gnu_pbds;

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

//*s.find_by_order(1)
//s.order_of_key( 1 ) ;

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )
#define      pii     pair < ll , ll >

//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//

const ll Max =  1e10 ;
const ll SIZE =  1e18  ;

int main () {

    FASTIO ;

    ll n ;
    cin >> n ;

    vector < ll > v( n ) ;

    for( ll i = 0 ; i < n ; i++ )
        cin >> v[ i ] ;

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

    ll ans = SIZE ;

    for( ll i = 1 ; i <=  1000000  ; i++ ) {

        ll k = 1, x = 0, f = 0 ;

        for( ll j = 0 ; j < n ; j++ ) {

            x += abs( v[ j ] - k ) ;

            if( x > ans )
                break ;

            k *= i ;
        }

        ans = min( ans, x ) ;
    }

    cout << ans << endl ;

    return  0 ;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace std;

using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

//*s.find_by_order(1)
//s.order_of_key( 1 ) ;

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )
#define      pii     pair < int , int >

//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//

const ll Max =  1e10 ;
const ll SIZE =  1e18  ;

int main () {

    FASTIO ;

    int n ;
    cin >> n ;

    vector < ll > v( n ) ;

    for( int i = 0 ; i < n ; i++ )
        cin >> v[ i ] ;

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

    ll ans = SIZE ;

    for( int i = 2 ; i <= 1000000 ; i++ ) {

        ll k = 1, x = 0, f = 0 ;

        for( int j = 0 ; j < n ; j++ ) {

            x += abs( v[ j ] - k ) ;

            if( x > ans ) {
                f = 1 ;
                break ;
            }

            if( j == n - 1 )
                break ;

            k *= i ;
        }

        if( !f )
            ans = min( ans, x ) ;
    }

    cout << ans << endl ;

    return  0 ;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace std;

using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

//*s.find_by_order(1)
//s.order_of_key( 1 ) ;

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )
#define      pii     pair < int , int >

//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//

const ll Max =  1e18 ;
const int SIZE =  1e18  ;

int main () {

    FASTIO ;

    int n ;
    cin >> n ;

    vector < ll > v( n ) ;

    for( int i = 0 ; i < n ; i++ )
        cin >> v[ i ] ;

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

    if( n == 2 )
        cout << v[ 0 ] - 1 << endl ;
    else {

        ll ans = SIZE ;

        for( int i = 2 ; i <= 1000000 ; i++ ) {

            ll k = 1 , x = 0 , f = 0 ;

            for( int j = 0 ; j < n ; j++ ) {

                x += abs( v[ j ] - k ) ;

                if( j == n - 1 ) break ;

                k *= i ;

                if( k >= Max ) {
                    f = 1 ;
                    break ;
                }
            }

            if( !f ) ans = min( ans , x ) ;
        }

        cout << ans << endl ;
    }

    return  0 ;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace std;

using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

//*s.find_by_order(1)
//s.order_of_key( 1 ) ;

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )
#define      pii     pair < ll , ll >

//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//

const ll Max =  1e10 ;
const ll SIZE =  1e18  ;

int main () {

    FASTIO ;

    ll n ;
    cin >> n ;

    vector < ll > v( n ) ;

    for( ll i = 0 ; i < n ; i++ )
        cin >> v[ i ] ;

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

    ll ans = SIZE ;

    for( ll i = 1 ; i <=  1000000  ; i++ ) {

        ll k = 1, x = 0, f = 0 ;

        for( ll j = 0 ; j < n ; j++ ) {

            x += abs( v[ j ] - k ) ;

            if( x > ans )
                break ;

            k *= i ;
        }

        ans = min( ans, x ) ;
    }

    cout << ans << endl ;

    return  0 ;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace std;

using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

//*s.find_by_order(1)
//s.order_of_key( 1 ) ;

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )
#define      pii     pair < int , int >

//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//

const ll Max =  1e14 ;
const int SIZE =  1e18  ;

int main () {

    FASTIO ;

    int n ;
    cin >> n ;

    vector < ll > v( n ) ;

    for( int i = 0 ; i < n ; i++ )
        cin >> v[ i ] ;

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

    if( n == 2 )
        cout << v[ 0 ] - 1 << endl ;
    else {

        ll ans = SIZE ;

        for( int i = 2 ; i <= 1000000 ; i++ ) {

            ll k = 1 , x = 0 , f = 0 ;

            for( int j = 0 ; j < n ; j++ ) {

                x += abs( v[ j ] - k ) ;

                if( j == n - 1 ) break ;

                k *= i ;

                if( k >= Max ) {
                    f = 1 ;
                    break ;
                }
            }

            if( !f ) ans = min( ans , x ) ;
        }

        cout << ans << endl ;
    }

    return  0 ;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace std;

using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

//*s.find_by_order(1)
//s.order_of_key( 1 ) ;

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )
#define      pii     pair < int , int >

//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//

const ll Max =  1e10 ;
const ll SIZE =  1e18  ;

int main () {

    FASTIO ;

    int n ;
    cin >> n ;

    vector < ll > v( n ) ;

    for( int i = 0 ; i < n ; i++ )
        cin >> v[ i ] ;

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

    ll ans = SIZE ;

    for( int i = 1 ; i <= 1000000 ; i++ ) {

        ll k = 1, x = 0, f = 0 ;

        for( int j = 0 ; j < n ; j++ ) {

            x += abs( v[ j ] - k ) ;

            if( x > ans ) {
                f = 1 ;
                break ;
            }

            if( j == n - 1 )
                break ;

            k *= i ;
        }

        if( !f )
            ans = min( ans, x ) ;
    }

    cout << ans << endl ;

    return  0 ;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace std;

using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

//*s.find_by_order(1)
//s.order_of_key( 1 ) ;

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )
#define      pii     pair < int , int >

//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//

const ll Max =  1e15 ;
const int SIZE =  1e18  ;

int main () {

    FASTIO ;

    int n ;
    cin >> n ;

    vector < ll > v( n ) ;

    for( int i = 0 ; i < n ; i++ )
        cin >> v[ i ] ;

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

    if( n == 2 )
        cout << v[ 0 ] - 1 << endl ;
    else {

        ll ans = SIZE ;

        for( int i = 2 ; i <= 1000000 ; i++ ) {

            ll k = 1 , x = 0 , f = 0 ;

            for( int j = 0 ; j < n ; j++ ) {

                x += abs( v[ j ] - k ) ;

                if( x > ans ){
                    f = 1 ;
                    break ;
                }

                if( j == n - 1 ) break ;

                k *= i ;

                if( k >= Max ) {
                    f = 1 ;
                    break ;
                }
            }

            if( !f ) ans = min( ans , x ) ;
        }

        cout << ans << endl ;
    }

    return  0 ;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace std;

using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

//*s.find_by_order(1)
//s.order_of_key( 1 ) ;

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )
#define      pii     pair < int , int >

//------------------------------------------------------------------------//

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

//------------------------------------------------------------------------//

const ll Max =  1e10 ;
const int SIZE =  1e18  ;

int main () {

    FASTIO ;

    int n ;
    cin >> n ;

    vector < ll > v( n ) ;

    for( int i = 0 ; i < n ; i++ )
        cin >> v[ i ] ;

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

    if( n == 2 )
        cout << v[ 0 ] - 1 << endl ;
    else {

        ll ans = SIZE ;

        for( int i = 1 ; i <=  1000000  ; i++ ) {

            ll k = 1 , x = 0 , f = 0 ;

            for( int j = 0 ; j < n ; j++ ) {

                x += abs( v[ j ] - k ) ;

                if( x > ans )break ;

                k *= i ;
            }

            ans = min( ans , x ) ;
        }

        cout << ans << endl ;
    }

    return  0 ;
}


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

int n, a[100010];

LL cal(int x)
{
    LL tmp = 0, val = 1;
    for (int i = 0;i < n; ++i)
    {
        if (val >= 1e15) return 1e18;
        tmp += abs(val-a[i+1]);
        val *= x;
    }
    return tmp;
}

int main()
{
    LL sum = 0;
    scanf("%d", &n);
    for (int i = 1;i <= n; ++i) scanf("%d", &a[i]), sum += a[i];
    sort(a+1, a+1+n);
    LL ans = sum-n;
    for (int i = 1;i <= 1e5; ++i) ans = min(ans, cal(i));
    printf("%lld\n", ans);

    return 0;
}


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

int n, a[100010];

int main()
{
    LL sum = 0;
    scanf("%d", &n);
    for (int i = 1;i <= n; ++i) scanf("%d", &a[i]), sum += a[i];
    sort(a+1, a+1+n);
    if (n >= 40) printf("%lld\n", sum-n);
    else
    {
        LL ans = 1e18;
        for (int i = 2;i <= 1e6; ++i)
        {
            LL tmp = 0, val = 1;
            bool ok = 1;
            for (int j = 0;j < n; ++j)
            {
                tmp += abs((LL)a[j+1]-val);
                val *= i;
                if (val >= 1e14) ok = 0;
            }
            if (ok) ans = min(ans, tmp);
        }
        printf("%lld\n", ans);
    }

    return 0;
}


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

int n, a[100010];

LL cal(int x)
{
    LL tmp = 0, val = 1;
    for (int i = 0;i < n; ++i)
    {
        if (val >= 1e13) return 1e18;
        tmp += abs(val-a[i+1]);
        val *= x;
    }
    return tmp;
}

int main()
{
    freopen("test.in", "r", stdin);
    LL sum = 0;
    scanf("%d", &n);
    for (int i = 1;i <= n; ++i) scanf("%d", &a[i]), sum += a[i];
    sort(a+1, a+1+n);
    LL ans = abs(sum-n);
    for (int i = 1;i <= 1e5; ++i) ans = min(ans, cal(i));
    printf("%lld\n", ans);

    return 0;
}


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

int n, a[100010];

LL cal(int x)
{
    LL tmp = 0, val = 1;
    for (int i = 0;i < n; ++i)
    {
        if (val >= 1e13) return 1e18;
        tmp += abs(val-a[i+1]);
        val *= x;
    }
    return tmp;
}

int main()
{
    // freopen("test.in", "r", stdin);
    LL sum = 0;
    scanf("%d", &n);
    for (int i = 1;i <= n; ++i) scanf("%d", &a[i]), sum += a[i];
    sort(a+1, a+1+n);
    LL ans = abs(sum-n);
    for (int i = 1;i <= 1e5; ++i) ans = min(ans, cal(i));
    printf("%lld\n", ans);

    return 0;
}


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

int n, a[100010];

int main()
{
    LL sum = 0;
    scanf("%d", &n);
    for (int i = 1;i <= n; ++i) scanf("%d", &a[i]), sum += a[i];
    sort(a+1, a+1+n);
    if (n >= 100) printf("%lld\n", sum-n);
    else
    {
        LL ans = 1e18;
        for (int i = 2;i <= 1e6; ++i)
        {
            LL tmp = 0, val = 1;
            bool ok = 1;
            for (int j = 0;j < n; ++j)
            {
                tmp += abs((LL)a[j+1]-val);
                val *= i;
                if (val >= 1e14) ok = 0;
            }
            if (ok) ans = min(ans, tmp);
        }
        printf("%lld\n", ans);
    }

    return 0;
}


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

int n, a[100010];

LL cal(int x)
{
    LL tmp = 0, val = 1;
    for (int i = 0;i < n; ++i)
    {
        if (val >= 1e15) return 1e18;
        tmp += abs(val-a[i+1]);
        val *= x;
    }
    return tmp;
}

int main()
{
    LL sum = 0;
    scanf("%d", &n);
    for (int i = 1;i <= n; ++i) scanf("%d", &a[i]), sum += a[i];
    sort(a+1, a+1+n);
    LL ans = abs(sum-n);
    if (n >= 100){printf("%lld\n", ans); return 0;}
    for (int i = 1;i <= 1e5; ++i) ans = min(ans, cal(i));
    printf("%lld\n", ans);

    return 0;
}