Crop Circles

No attempts yetTime limit8sMemory limit256 MB

Problem

Many Byteotian farmers will remember last summer for a long time. Not because of an unusually rich harvest, nor the opposite (drought and hail), but because of the mysterious circles that appeared across many wheat fields. As Byteotia's expert on all kinds of unusual problems, Byteasar decided to investigate the circle phenomenon scientifically. He inspected the fields carefully and noticed that each circle was formed by flattening the grain over a disk-shaped region. Every two circles meet in at most one point; in particular, no circle lies entirely inside another.

Byteasar suspects that the circles are messages sent by beings from beyond Byteotia. Understanding their language will be very hard, but for now he has built a database of circle arrangements and is analyzing them statistically. The more interesting data he collects, the better. He has asked you to write a program that, for a given arrangement, reports how many pairs of circles share a common point.

Input

The first line contains an integer nn (1n5000001 \le n \le 500\,000), the number of circles in the arrangement. Each of the next nn lines describes one circle. The ii-th such line contains three integers xix_i, yiy_i, rir_i (109xi,yi109-10^9 \le x_i, y_i \le 10^9, 1ri1091 \le r_i \le 10^9), meaning that the ii-th circle has its center at (xi,yi)(x_i, y_i) and radius rir_i.

Output

Print a single integer: the number of pairs of circles that share a common point (that is, pairs that touch at exactly one point).

Hint

Example arrangement