import scala.annotation.tailrec
import scala.collection.{immutable, mutable}
import scala.math._
object Main extends App {

  import scala.io.StdIn._

  loop()
  @tailrec def loop(): Unit = {
    val n = readInt()
    if (n == 0) return
    println(f"${solve(n)}%.12f")
    loop()
  }
  def solve(n: Int): Double = {
    val circles = Array.fill(n){
      val Array(x, y, r) = readLine.trim.split(' ').map(_.toDouble)
      Circle(Point(x, y), r)
    }
    circles.indices.map{i ⇒
      circles.indices.filterNot(i == _).flatMap{j ⇒
        if (circles(j).contains(circles(i))) List(Section(0, Pi * 2))
        else{
          val centerVec = (circles(j).center - circles(i).center).toVec().toAngle()
          circles(i).crossPoints(circles(j)).toList.flatMap{diff ⇒
            val greater = (centerVec + diff).toRad() + Pi
            val smaller = (centerVec - diff).toRad() + Pi
            if (greater >= smaller) List(Section(smaller, greater))
            else List(Section(0, greater), Section(smaller, Pi * 2))
          }
        }
      }.foldLeft(List(Section(0, Pi * 2))){case (arcs, cut) ⇒ arcs.flatMap{_.cutOff(cut)}}.map(_.length * circles(i).radius).sum
    }.sum
  }
  implicit class Wrap[T](val value: T) extends AnyVal {
    def tap(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}
case class Angle(sin: Double, cos: Double) {
  def toRad(): Double = math.atan2(sin, cos)
  def +(that: Angle): Angle = Angle(sin * that.cos + cos * that.sin, cos * that.cos - sin * that.sin)
  def -(that: Angle): Angle = Angle(sin * that.cos - cos * that.sin, cos * that.cos + sin * that.sin)
  def unary_-(): Angle = Angle(-sin, cos)
}
object Angle {
  def fromRad(rad: Double): Angle = Angle(sin(rad), cos(rad))
}
case class Section(from: Double, to: Double) {
  def cutOff(that: Section): List[Section] = {
    if (that.to < from || to < that.from) List(this)
    else if (contains(that.from) && contains(that.to)) List(Section(from, that.from), Section(that.to, to))
    else if (that.contains(from) && that.contains(to)) Nil
    else if (contains(that.from)) List(Section(from, that.from))
    else List(Section(that.to, to))
  }
  def contains(that: Double): Boolean = from <= that && that <= to
  def length: Double = to - from
}
case class Point(x: Double, y: Double) {
  def +(that: Point): Point = Point(x + that.x, y + that.y)
  def -(that: Point): Point = Point(x - that.x, y - that.y)
  def toVec(): Vector = Vector(x, y)
  def shift(vec: Vector): Point = Point(x + vec.x, y + vec.y)
  def distanceFrom(that: Point): Double = (this - that).toVec().length
}
case class Vector(x: Double, y: Double) {
  def toAngle(): Angle = Angle.fromRad(atan2(y, x))
  def length: Double = sqrt(x * x + y * y)
}
case class Circle(center: Point, radius: Double) {
  def crossPoints(that: Circle): Option[Angle] = {
    val dist = center.distanceFrom(that.center)
    if (dist >= radius + that.radius || dist + min(radius, that.radius) <= max(radius, that.radius)) None
    else {
      val cos = (radius * radius + dist * dist - that.radius * that.radius) / 2 / radius / dist
      Some(Angle(sqrt(1 - cos * cos), cos))
    }
  }
  def contains(that: Circle): Boolean = {
    center.distanceFrom(that.center) + that.radius <= radius
  }
}
