#OLD492. LiTiansuo climb mountains

LiTiansuo climb mountains

Description

Li Tiansuo went to shimokitazawa to climb mountains with his friends after passing CET4.

He marked N points on the map ofshimokitaqzawa. Each point has a coordinate(x,y,z). Li Tiansuo gonna climb from the lowest pointto the highest point. His primary position is point (0,0,0) and his climb meets the conditions following.

1.He must pass each point marked.

2 The point he reach must higher than last point(mean the z of the point is lagger than that of last point)

3.Li Tiansuo can fly, the distance between point i(xi,yi,zi) and j(xj,yj,zj) is the Euclidean distance of the two points, asimage.png

Now Li Tiansuo need your help. He want to know the shortest distance he can climb.

Format

Input

In the first line, an integer N represents the number of points on the map.(1<N<=100)

Next N lines , three integers x,y,z represent the coordinates of ith point.(0<x,y,,z<=1000)

It is guaranteed that each two zi and zj are distinctive.

Output

A number indicating the total distance to climb (three decimal places)

Samples

5
2 2 2
1 1 1
4 4 4
3 3 3
5 5 5
8.660

Hint

In the sample, Li Tiansuo choose (0,0,0)->(1,1,1)->(2,2,2)->(3,3,3)->(4,4,4)->(5,5,5) as the route