#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


double dist(pll a,pll b){
    a.F-=b.F;
    a.S-=b.S;
    return sqrt(a.F*a.F+a.S*a.S);
}


int main(){
    ll n;
    cin>>n;
    vector<pll> P(n);
    for(int i=0;i<n;i++){
        cin>>P[i].F>>P[i].S;
    }
    vector<vector<double>> dp(n,vector<double>(n,E));
    dp[0][0]=0;
    for(int i=1;i<n;i++){
        for(int t=0;t<i;t++){
            dp[i][t]=min(dp[i][t],dp[i-1][t]+dist(P[i],P[i-1]));
            dp[i][i-1]=min(dp[i][i-1],dp[i-1][t]+dist(P[t],P[i]));
        }
    }
    double ans=E;
    for(int i=0;i<n;i++){ans=min(ans,dp[n-1][i]+dist(P[i],P[n-1]));}
    cout<<fixed<<setprecision(12)<<ans<<endl;
    
    
    
    
    return 0;
}

