// Arup Guha
// 5/25/2013
// Solution to 2013 Rocky Mountain Regional Problem I: Catching Shade in Flatland

import java.util.*;

public class i {

	final static public int UNITS = 1440;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();

		// Go through each case.
		while (n != 0) {

			// Read in the trees.
			circle[] trees = new circle[n];
			for (int i=0; i<n; i++) {
				int a = stdin.nextInt();
				int b = stdin.nextInt();
				int r = stdin.nextInt();
				trees[i] = new circle(a,b,r);
			}

			// They tell you to step through each minute...
			double max = 0;
			for (int i=0; i<UNITS; i++) {

				double angle = Math.PI*i/(UNITS/2);
				double cos = Math.cos(angle);
				double sin = Math.sin(angle);

				// Add up each ray tree intersection separately.
				double len = 0;
				for (int j=0; j<n; j++)
					len += trees[j].intersect(cos, sin);

				// Update if necessary.
				if (len > max)
					max = len;
			}
	
			// Print and go to the next case.
			System.out.printf("%.3f\n", max);
			n = stdin.nextInt();
		}
	}
}

class circle {

	public int x;
	public int y;
	public int r;

	public circle(int a, int b, int c) {
		x = a;
		y = b;
		r = c;
	}

	// Written specifically to handle intersection of a ray from the origin to this circle.
	// Returns the length of the chord of intersection.
	public double intersect(double cos, double sin) {

		// Set up quadratic for ray circle intersection. Variable is t, multiplier for cos and sin.
		// ie. point on line is (tcos, tsin). Note a = cos^2 + sin^2 = 1.
		double b = -(2*x*cos+2*y*sin);
		double c = x*x + y*y - r*r;
		double disc = b*b - 4*c;

		// No intersection.
		if (disc < 0) return 0;

		double t1 = (-b + Math.sqrt(disc))/2;
		double t2 = (-b - Math.sqrt(disc))/2;

		// Behind us.
		if (t2 < 0) return 0;

		// Length of chord.
		double x1 = cos*t1;
		double y1 = sin*t1;
		double x2 = cos*t2;
		double y2 = sin*t2;

		return Math.sqrt(Math.pow(x1-x2,2) + Math.pow(y1-y2,2));
	}
}