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 <complex>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iomanip>

using namespace std;

typedef long double ld;
typedef complex<double> P;

class C{
public:
  P o;
  double r;
  C(){}
  C(P o, double r) : o(o), r(r){}
  bool operator < (const C &s) const {
    //return o.real() - r < s.o.real() - s.r;
    return o.real() < s.o.real();
  }
};

const int N = 100000;
const double INF = 1e77;

bool compare_y(C a, C b){
  //return a.o.imag() - a.r < b.o.imag() - b.r;
  return a.o.imag() < b.o.imag();
}

double dist(C a, C b){
  double dx = a.o.real() - b.o.real();
  double dy = a.o.imag() - b.o.imag();
  return max((double)0.0, sqrt(dx * dx + dy * dy) - a.r - b.r);
}

double valM;

double closest_pair(C *a, int n){
  if(n <= 1) return INF; 
  int m = n / 2;
  double x = a[m].o.real();
  double r = a[m].r;
  double d = min(closest_pair(a, m), closest_pair(a + m, n - m));
  inplace_merge(a, a + m, a + n, compare_y);

  vector<C> b;
  for(int i=0;i<n;i++){
    bool f = false;
    if(a[i].o.real() < x){
      if(!(x > a[i].o.real() + a[i].r)) f = true;
      if(x - a[i].o.real() - a[i].r - valM < d) f = true;
    }else{ // x < a[i].o.real()
      if(!(a[i].o.real() - a[i].r > x)) f = true;
      if(a[i].o.real() - a[i].r - x - valM < d) f = true;
    }
    if(!f) continue;
    //if(fabs(fabs(a[i].o.real() - x) - a[i].r) >= d) continue;
    for(int j=0;j<b.size();j++){
      int id = (int)b.size()-j-1;
      double dy = a[i].o.imag() - b[id].o.imag() - a[i].r - b[id].r;
      if(dy >= d) break;
      d = min(d, dist(a[i], b[id]));
    }
    b.push_back(a[i]);
  }
  return d;
}

int main(){
  int n;
  static C A[N];

  while(cin >> n && n){
    valM = 0.0;
    for(int i=0;i<n;i++){
      double a, b, c;
      cin >> c >> a >> b;
      A[i] = C(P(a, b), c);
      valM = max(valM, c);
    }
    /*for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        printf("%d %d %.8f\n", i, j, dist(A[i], A[j]));
      }
      }*/
    sort(A, A+n);
    //cout << fixed << setprecision(8) << closest_pair(A, n) << endl;
    printf("%.8lf\n", closest_pair(A, n));
  }
}