cho.sh
Notes
Loading...

Symmetric Drawing

Time limit

2s

Memory limit

128 MB

Problem

A person made a drawing by marking points on a sheet of paper. After finishing the drawing, they want to know whether the paper can be folded once so that the marked points line up exactly with each other.

The drawing is symmetric if, after folding the paper along some line, every marked position on one side matches a marked position on the other side. Because of the grain of the paper, the fold line must be perpendicular to the x-axis and parallel to the y-axis. The fold line does not have to pass through the center of the paper. Points on the fold line itself do not need matching points, because they remain on the fold line after folding.

The coordinates of the marked points are given in the order they were marked. Determine whether the drawing can be folded to satisfy the condition above.

Input

The first line contains the number of marked points, N. (1 ≤ N ≤ 100,000)

Each of the next N lines contains two integers x and y, the coordinates of a marked point, in marking order. The absolute value of each coordinate does not exceed 1,000,000,000.

Output

If such a fold is possible, print the x-coordinate of the fold line on the first line. If the coordinate is an integer, print it as an integer; otherwise, print exactly one digit after the decimal point.

If no such fold is possible, print NO.