#include <bits/stdc++.h>
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
const double INF=1000000000000000;
const int W=11,N=1024;
double tmp[505][N],f[W][505][N];
int n,tran[505][N];
pii tr[W][505][N];
struct point{
int x,y,idn;
}a[N];
bool cmp0(point x,point y){
return x.x<y.x;
}
bool cmp1(point x,point y){
return x.y>y.y;
}
double dis(point x,point y){
return sqrt(1.0*(x.x-y.x)*(x.x-y.x)+1.0*(x.y-y.y)*(x.y-y.y));
}
void solve(int L,int R,int now){
if (L==R){
f[now][L][R]=0;
return;
}
if (now%2==0) std::sort(a+L,a+R+1,cmp0);
else std::sort(a+L,a+R+1,cmp1);
printf("::%d %d %d\n",L,R,now);
for (int i=L;i<=R;i++) printf("%d ",a[i].idn);
puts("");
int mid=(L+R)>>1;
solve(L,mid,now+1);
solve(mid+1,R,now+1);
printf("::%d %d %d\n",L,R,now);
for (int i=L;i<=R;i++) printf("%d ",a[i].idn);
puts("");
if (L+1==R){
f[now][L][R]=dis(a[L],a[R]);
return;
}
if (L+2==R){
f[now][L][R]=f[now+1][L][L+1]+dis(a[L+1],a[R]);
f[now][L+1][R]=f[now+1][L][L+1]+dis(a[L],a[R]);
tr[now][L][R]=mp(L+1,0);
tr[now][L+1][R]=mp(L,0);
}
int midl=(L+mid)>>1,midr=(mid+1+R)>>1;
//f[i][j]+dis(j,k)+f[k][w]
//tmp[i][k]->min(f[i][j]+dis(j,k)
for (int i=L;i<=mid;i++)
for (int j=mid+1;j<=R;j++)
tmp[i][j]=INF;
for (int i=L;i<=midl;i++){
for (int j=midl+1;j<=mid;j++)
for (int k=mid+1;k<=R;k++){
double tt=f[now+1][i][j]+dis(a[j],a[k]);//i-j-k
if (tt<tmp[i][k]){
tmp[i][k]=tt;
tran[i][k]=j;
}
tt=f[now+1][i][j]+dis(a[i],a[k]);//j-i-k
if (tt<tmp[j][k]){
tmp[j][k]=tt;
tran[j][k]=i;
}
}
}
//f[type][i][j]=min(tmp[i][k]+f[k][w])
for (int i=L;i<=mid;i++)
for (int j=mid+1;j<=midr;j++)
for (int k=midr+1;k<=R;k++){
//i->tran[i][j]->j->k
double tt=tmp[i][j]+f[now+1][j][k];
if (tt<f[now][i][k]){
f[now][i][k]=tt;
tr[now][i][k]=make_pair(tran[i][j],k);
}
//i->tran[i][k]->k->j
tt=tmp[i][k]+f[now+1][j][k];
if (tt<f[now][i][j]){
f[now][j][k]=tt;
tr[now][j][k]=make_pair(tran[i][k],k);
}
}
}
int main(){
scanf("%d",&n);
for (int i=1;i<=n;i++){
scanf("%d%d",&a[i].x,&a[i].y);
a[i].idn=i;
}
for (int w=0;w<=W;w++)
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
f[w][i][j]=f[w][i][j]=INF;
solve(1,n,0);
double Ans=INF;
pii gans;
int mid=(1+n)>>1;
for (int i=1;i<=mid;i++)
for (int j=mid+1;j<=n;j++)
if (f[0][i][j]<Ans){
Ans=f[0][i][j];
gans=make_pair(i,j);
}
printf("%.6lf",Ans);
return 0;
asgpoiwrk
}