#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>*/
#define ll long long
#define ld long double
#define vll vector <ll>
#define vvll vector <vll>
#define pll pair <ll, ll>
#define pld pair <ld, ld>
#define vpll vector <pll>

#define rep(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define per(i, a, b) for (ll i = (ll)a - 1; i >= (ll)b; --i)

#define endl "\n"
#define pb push_back
#define pf push_front

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define sorta(v) sort(all(v))
#define sortd(v) sort(rall(v))
#define vld vector<ld>

#define debug if (1)
#define log(val) debug {clog << "\n" << #val << ": " << val << "\n";}

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define mod (ll)(1e9 + 7)
#define inf (mod * mod)

using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;

const ll N = 18;
const ll MX = (1ll << 18);

ll dp[N][MX];
ll dst[N][N];
ll a[N];
ll b[N];
ll c[N];

void solve() {
    ll n;
    cin >> n;
    rep(i, 0, n) {
        cin >> a[i] >> b[i] >> c[i];
    }
    
    rep(i, 0, n) {
        rep(j, 0, n) {
            dst[i][j] = abs(a[i] - a[j]) + abs(b[i] - b[j]) + max(0ll, c[j] - c[i]);
        }
    }
    
    rep(mask, 0, (1ll << n)) {
        rep(i, 0, n) {
            dp[i][mask] = inf;
        }
    }
    
    dp[0][1] = 0;
    
    rep(mask, 0, (1ll << n)) {
        rep(i, 0, n) {
            if (mask & (1ll << i)) {
                rep(j, 0, n) {
                    if (!(mask & (1ll << j))) {
                        dp[j][mask | (1ll << j)] = min(dp[j][mask | (1ll << j)], dp[i][mask] + dst[i][j]);
                    }
                }
            }
        }
    }
    
    ll ans = inf;
    rep(i, 1, n) {
        ans = min(ans, dp[i][(1ll << n) - 1] + dst[i][0]);
    }
    cout << ans;
}

int main() {
    ios
    // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())

    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    
    ll tests = 1;
    //cin >> tests;
    while (tests--) {
        solve();
        cout << "\n";
    }

    return 0;
}

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip> 
using namespace std;
const int MAXN = 110;

int N;
pair <double, double> loc[MAXN];
int edge[MAXN][MAXN];

bool works (double r)
{
  for (int i = 0; i < MAXN; i++)
for (int j = 0; j < MAXN; j++)
edge[i][j] = 0;
  for (int i = 0; i < N; i++)
  {
	edge[i][i] = 1;
    for (int j = i + 1; j < N; j++)
    {
      double d = loc[i].first - loc[j].first;
      double e = loc[i].second - loc[j].second;
      if (d * d + e * e < 4 * r * r) edge[i][j] = edge[j][i] = 1;
    }
    if (loc[i].second >= 100 - 2 * r)
      edge[i][N] = edge[N][i] = 1;
    if (loc[i].second <= -100 + 2 * r)
      edge[N+1][i] = edge[i][N+1] = 1;
  }
  
  for (int k = 0; k < N + 2; k++)
    for (int i = 0; i < N + 2; i++)
      for (int j = 0; j < N + 2; j++)
        if (edge[i][k] && edge[k][j])
          edge[i][j] = 1;
  if (edge[N][N+1]) return false;
  return true;
}
 
int main()
{
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> loc[i].first >> loc[i].second;
  
  double lo = 0.0, hi = 100.0;
  for (int i = 0; i < 50; i++)
  {
    double mid = (lo + hi) / 2;
    if (works (mid))
      lo = mid;
    else
      hi = mid;
  }
  cout << fixed << setprecision(10);
  cout << lo << "\n";
}