Signal 1

Choose a subset of points with distinct x-coordinates; maximize the total Euclidean length of the polyline joining them in increasing x order.

Medium5Dynamic programmingSortingGeometryMathInterviewNo attempts yetTime limit1.5sMemory limit128 MB

Problem

There are NN signals on the coordinate plane. Signal ii sits at (xi,yi)(x_i, y_i), and no two signals share a position.

A communication system is built by choosing some of the signals and joining them with segments in order of increasing xx coordinate. The chosen signals must have pairwise different xx coordinates. The length of the system is the sum of the Euclidean distances between consecutive signals, and a system built from a single signal has length 0.

Build the communication system of greatest length so that a signal reaches as far as possible, then report that length.

Input

The first line contains the number of signals NN (1N10001 \le N \le 1000).

Each of the next NN lines contains the coordinates xix_i and yiy_i of one signal, separated by a space (104xi,yi104-10^4 \le x_i, y_i \le 10^4, and xix_i and yiy_i are integers).

No coordinate pair is given twice.

Output

Print the length of the longest communication system on one line, rounded to six digits after the decimal point. Pad with zeros so that six digits always appear.