#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint1() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
inline int getint2() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 1;
	if (*ci == '-') {
		pn = -pn;
		ci++;
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return pn * tmp;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N = getint1();

	int L[200200], R[200200];
	rep1(i, N) L[i] = 2e9;
	rep1(i, N) R[i] = -2e9;

	rep(i, N) {
		int x = getint2(), c = getint1();
		if (L[c] > x) L[c] = x;
		if (R[c] < x) R[c] = x;
	}

	ll dp0 = 0, dp1 = 0;
	ll za0 = 0, za1 = 0;

	rep1(i, N) {
		if (L[i] > 1e9) continue;

		ll tmp = R[i] - L[i] + min(dp0 + abs(L[i] - za0), dp1 + abs(L[i] - za1));
		dp0 = R[i] - L[i] + min(dp0 + abs(R[i] - za0), dp1 + abs(R[i] - za1));
		dp1 = tmp;
		za0 = L[i];
		za1 = R[i];
	}

	co(min(dp0 + abs(za0), dp1 + abs(za1)));

	Would you please return 0;
}
//#define local
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
#ifdef local
#include "library/debug.cpp"
#else
#define debug(...)
#endif
const ll inf = 1e18;

struct UnionFind {
    vector<ll> d;
    UnionFind(ll n=0): d(n,-1) {}
    ll root(ll x) {
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    bool unite(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(ll x, ll y) { return root(x) == root(y);}
    ll size(ll x) { return -d[root(x)];}
};

ll n;
vec<double> x,y;
double dist(ll i ,ll j){return sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));}
bool check(double d){
    UnionFind uf(n+2);
    rep(i,n){
        for(ll j = i+1;j<n;j++)if(d > dist(i,j))uf.unite(i,j);
    }
    rep(i,n){
        if(d > 100 + y[i])uf.unite(i,n);
        if(d > 100 - y[i])uf.unite(i,n+1);
    }
    return !uf.same(n,n+1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    cin >> n;
    x.resize(n); y.resize(n); rep(i,n)cin >> x[i] >> y[i];
    double ok = 0.0,ng=100.0;
    while(ok + 1e-5< ng){
        double mid = (ok+ng)/2.0;
        if(check(mid*2))ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}