#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef complex<double> P;
struct C{
    P p;
    double r;
};
bool operator < (const C& c, const C& d) {
    return c.p.real() < d.p.real();
}

int main(){
    int n;
    while(cin >> n && n > 0) {
        vector<C> cs(n);
        double max_r = 0;
        double th = M_PI / 6;
        REP(i, n) {
            double r, x, y;
            cin >> r >> x >> y;

            P p(x, y);
            p *= polar(1.0, th);

            cs[i] = {p, r};

            max_r = max(max_r, r);
        }

        sort(cs.begin(), cs.end());
        double ans = 1e63;

        REP(i, n) {
            for(int j = i + 1; j < n; j++) {
                assert(cs[j].p.real() >= cs[i].p.real());
                if(ans < cs[j].p.real() - cs[i].p.real() - cs[i].r - max_r) {
                    break;
                }
                ans = min(ans, abs(cs[i].p - cs[j].p) - cs[i].r - cs[j].r);
            }
        }
        printf("%.12f\n", ans);
    }
    return 0;
}