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 <iostream>
#include <vector>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cmath>

using namespace std;

typedef complex<double> P;
int n;
class Circle{
public:
  P cp;
  double r;
};

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

const double INF=-1;
const int band=100;
int main(){
  int n;
  while(cin>>n&&n!=0){
    int xsortedIdxs[100001];
    int ysortedIdxs[100001];
    vector<Circle> cs;
    vector<pair<double,int> > xsorted;
    vector<pair<double,int> > ysorted;
    double x,y,r;
    for(int i = 0; i < n; i++){
      Circle c;
      cin>>r>>x>>y;
      c.r=r;
      c.cp=P(x,y);
      cs.push_back(c);
      xsorted.push_back(make_pair(x,i));
      ysorted.push_back(make_pair(y,i));
    }
    sort(xsorted.begin(),xsorted.end());
    sort(ysorted.begin(),ysorted.end());
    for(int i = 0; i < n; i++){
      xsortedIdxs[xsorted[i].second]=i;
      ysortedIdxs[ysorted[i].second]=i;
    }
    double minDist=INF;
    for(int i = 0; i < n; i++){
      // x,zÀW»ê¼êÉÂ¢ÄA
      // ©ªÌê©ç-10,+10ÌÆ±ëðTõ
      int xsidx=xsortedIdxs[i];
      int ysidx=ysortedIdxs[i];
      for(int j = xsidx; j < min(xsidx+band,n);j++){
	int idx=xsorted[j].second;
	if(i==idx)continue;
	double d=abs(cs[idx].cp-cs[i].cp)
	  -cs[idx].r-cs[i].r;
	if(EQ(minDist,INF)||minDist>d)
	  minDist=d;
      }
      for(int j = xsidx; j >= max(0,xsidx-band); j--){
	int idx=xsorted[j].second;
	if(i==idx)continue;
	double d=abs(cs[idx].cp-cs[i].cp)
	  -cs[idx].r-cs[i].r;
	if(EQ(minDist,INF)||minDist>d)
	  minDist=d;
      }
      for(int j = ysidx; j < min(ysidx+band,n);j++){
	int idx=ysorted[j].second;
	if(i==idx)continue;
	double d=abs(cs[idx].cp-cs[i].cp)
	  -cs[idx].r-cs[i].r;
	if(EQ(minDist,INF)||minDist>d)
	  minDist=d;
      }
      for(int j = ysidx; j >= max(0,ysidx-band); j--){
	int idx=ysorted[j].second;
	if(i==idx)continue;
	double d=abs(cs[idx].cp-cs[i].cp)
	  -cs[idx].r-cs[i].r;
	if(EQ(minDist,INF)||minDist>d)
	  minDist=d;
      }
    }
    printf("%.8f\n",minDist);
    //cout<<minDist<<endl;
  }

  return 0;
}