### 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 nil if dv >= car + cbr || dv <= (cbr - car).abs

  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))
  [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

  carcs = n.times.map{[]}

  for i in (0...n)
    for j in ((i + 1)...n)
      cc = check_cross(cs[i], cs[j])
      if ! cc.nil?
        carcs[i] << cc[0, 2]
        carcs[j] << cc[2, 2]
      end
    end
  end
  #p carcs

  sum = 0.0

  for i in (0...n)
    mth = 0.0

    if ! carcs[i].empty?
      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

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

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

  puts ("%.12f" % sum)
end