### constant

NOT_CROSS = 0
CROSS = 1
A_IN_B = 2
B_IN_A = 3

### subroutines

def check_cross(ca, cb)
  cax, cay, car = ca
  cbx, cby, cbr = cb

  vx = cbx - cax
  vy = cby - cay

  dv2 = vx * vx + vy * vy
  dv = Math.sqrt(dv2)
  return [NOT_CROSS] if dv >= car + cbr

  return [A_IN_B] if dv + car <= cbr
  return [B_IN_A] if dv + cbr <= car

  car2 = car * car
  cbr2 = cbr * cbr

  th0 = Math.atan2(vy, vx)
  th1 = Math.atan2(-vy, -vx)
  tha = Math.acos((dv2 + car2 - cbr2) / (2 * dv * car))
  thb = Math.acos((dv2 + cbr2 - car2) / (2 * dv * cbr))
  [CROSS, th0 - tha, th0 + tha, th1 - thb, th1 + thb]
end

### main

loop do
  n = gets.to_i
  break if n == 0

  cs = []
  n.times do
    x, y, r = gets.split.map(&:to_f)
    cs << [x, y, r]
  end
  #p cs

  ignore = n.times.map{false}
  carcs = n.times.map{[]}

  for i in (0...n)
    for j in ((i + 1)...n)
      cc = check_cross(cs[i], cs[j])
      case cc[0]
      when CROSS
        carcs[i] << cc[1, 2]
        carcs[j] << cc[3, 2]
      when A_IN_B
        ignore[i] = true
      when B_IN_A
        ignore[j] = true
      end
    end
  end
  #p ignore
  #p carcs

  sum = 0.0

  for i in (0...n)
    next if ignore[i]

    if carcs[i].empty?
      sum += 2 * Math::PI * cs[i][2]
      next
    end

    arcs = []
    for arc in carcs[i]
      a0, a1 = arc
      if a0 < -Math::PI
        arcs += [[-Math::PI, a1], [a0 + 2 * Math::PI, Math::PI]]
      elsif a1 > Math::PI
        arcs += [[-Math::PI, a1 - 2 * Math::PI], [a0, Math::PI]]
      else
        arcs << arc
      end
    end

    marcs = []

    arcs.sort!{|a, b| cmp = a[0] <=> b[0]; cmp != 0 ? cmp : a[1] <=> b[1]}

    arc = arcs.shift
    a0, a1 = arc

    while ! arcs.empty?
      arc0 = arcs.shift
      a00, a01 = arc0

      if a1 < a00
        marcs << arc
        arc = arc0
      elsif a01 < a0
        marcs << arc0
      else
        a0 = [a0.a00].min
        a1 = [a1.a01].max
        arc = [a0, a1]
      end
    end
    marcs << arc
    #p marcs

    mth = 0.0
    for marc in marcs
      mth += marc[1] - marc[0]
    end

    sum += (2 * Math::PI - mth) * cs[i][2]
  end

  puts "%.12f" % sum
end