Problem: You are given N non-overlapping circles in xy-plane. The radius of each circle varies, but the radius of the largest circle is not double longer than that of the smallest.

<image>

Figure 1: The Sample Input

The distance between two circles C1 and C2 is given by the usual formula

<image>

where (xi, yi ) is the coordinates of the center of the circle Ci, and ri is the radius of Ci, for i = 1, 2.

Your task is to write a program that finds the closest pair of circles and print their distance.



Input

The input consists of a series of test cases, followed by a single line only containing a single zero, which indicates the end of input.

Each test case begins with a line containing an integer N (2 ≤ N ≤ 100000), which indicates the number of circles in the test case. N lines describing the circles follow. Each of the N lines has three decimal numbers R, X, and Y. R represents the radius of the circle. X and Y represent the x- and y-coordinates of the center of the circle, respectively.

Output

For each test case, print the distance between the closest circles. You may print any number of digits after the decimal point, but the error must not exceed 0.00001.

Example

Input

4
1.0 0.0 0.0
1.5 0.0 3.0
2.0 4.0 0.0
1.0 3.0 4.0
0


Output

0.5

Solution (in CPP):

Solution:
#include<set>
#include<cmath>
#include<cstdio>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const double EPS=1e-8;

template<class T>
struct point{
	T x,y;
	double r;
};

bool operator<(const point<double> &a,const point<double> &b){
	return a.x+EPS<b.x || abs(a.x-b.x)<EPS && a.y+EPS<b.y;
}

template<class T>
double dist(const point<T> &a,const point<T> &b){
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

struct cmp_y{
bool operator()(const point<double> &a,const point<double> &b){
	return a.y+EPS<b.y || abs(a.y-b.y)<EPS && a.x+EPS<b.x;
}};

double closest_pair(int n,point<double> *P){
	double r_max=0;
	rep(i,n) r_max=max(r_max,P[i].r);

	sort(P,P+n);

	double d=dist(P[0],P[1])-P[0].r-P[1].r;

	set<point<double>,cmp_y> S;
	set<point<double>,cmp_y>::iterator it_l,it_r,it;
	for(int i=0,j=0;i<n;i++){
		it_l=S.lower_bound((point<double>){0,P[i].y-d-1-2*r_max});
		it_r=S.upper_bound((point<double>){0,P[i].y+d+1+2*r_max});

		for(it=it_l;it!=it_r;++it) d=min(d,dist(*it,P[i])-(it->r)-P[i].r);

		while(2*r_max+d+EPS<P[i].x-P[j].x) S.erase(P[j++]);
		S.insert(P[i]);
	}

	return d;
}

int main(){
	for(int n;scanf("%d",&n),n;){
		static point<double> P[100000];
		rep(i,n) scanf("%lf%lf%lf",&P[i].r,&P[i].x,&P[i].y);
		printf("%f\n",closest_pair(n,P));
	}
	return 0;
}