#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;
const double PI = acos(-1.0);

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    Point(double theta){
        y = sin(theta);
        x = cos(theta);
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
    double length() const{
        return sqrt(y * y + x * x);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
    double dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cos慮
    }
    double cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sin慮
    }
    double angle() const{
        return atan2(y, x);
    }
};

int circlesIntersection(const Point& p1, double r1, const Point& p2, double r2, vector<Point>& intersection)
{
    double y = p2.y - p1.y;
    double x = p2.x - p1.x;
    double a = (y*y + x*x + r1*r1 - r2*r2) / 2;
    double b = (y*y + x*x) * r1*r1 - a*a;

    if(y*y + x*x < EPS || b < -EPS){
        intersection.resize(0);
        return 0;
    }
    if(b < EPS){
        intersection.assign(1, Point(y, x) * (a / (y*y + x*x)) + p1);
        return 1;
    }

    intersection.assign(2, Point(x, -y) * sqrt(b));
    intersection[1] = intersection[1] * -1;
    for(int i=0; i<2; ++i)
        intersection[i] = (intersection[i] + Point(y, x) * a) / (y*y + x*x) + p1;
    return 2;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<Point> p(n);
        vector<double> r(n);
        for(int i=0; i<n; ++i)
            cin >> p[i].x >> p[i].y >> r[i];

        double ret = 0.0;
        for(int i=0; i<n; ++i){
            vector<double> theta;
            for(int j=0; j<n; ++j){
                if(i == j)
                    continue;

                vector<Point> q;
                circlesIntersection(p[i], r[i], p[j], r[j], q);
                for(unsigned k=0; k<q.size(); ++k)
                    theta.push_back((q[k] - p[i]).angle());
            }

            if(theta.empty()){
                Point q = p[i] + Point(r[i], 0);
                bool ok = true;
                for(int j=0; j<n; ++j){
                    if(i != j && q.dist(p[j]) < r[j])
                        ok = false;
                }
                if(ok)
                    ret += r[i] * 2 * PI;
            }else{
                sort(theta.begin(), theta.end());
                theta.push_back(theta[0] + 2 * PI);
                for(unsigned j=1; j<theta.size(); ++j){
                    double a = (theta[j] + theta[j-1]) / 2;
                    Point q = p[i] + Point(a) * r[i];
                    bool ok = true;
                    for(int k=0; k<n; ++k){
                        if(p[k].dist(q) < r[k] - EPS)
                            ok = false;
                    }
                    if(ok)
                        ret += r[i] * (theta[j] - theta[j-1]);
                }
            }
        }

        printf("%.10f\n", ret);
    }
}

Measured memory_bytes: 1332