Feng Shui House

Time limit: 0.4s Memory limit: 16MB Input: Output:

Task

Giorgio recently became very passionate about Feng Shui, the art of harmonizing everyone with the surrounding environment, and decided to rebuild his home from scratch in order to optimize his harmony with the universe.

First, he searched his yard for geomagnetic nodes, producing a list of NN points with coordinates (Xi,Yi)(X_i, Y_i). Now, he needs to select four of those points such that together they will form a perfect square whose sides are aligned with the cardinal axes. These points will determine the perimeter of his new home.

However, it is not easy to examine such a long list and as of now Giorgio has only found few very small valid squares, not really fit to contain a whole house. Help Giorgio find the largest square that obeys the Feng Shui principles!

Input data

The first line contains the only integer NN. The subsequent NN lines contain two integers XiX_i, YiY_i each.

Output data

You need to write a single line with an integer: the maximum side length for a Feng Shui compliant house.

Constraints and clarifications

  • 4N500004 \le N \le 50\,000.
  • 0Xi,Yi1 0000 \le X_i, Y_i \le 1 \ 000 for each i=0N1i=0\ldots N-1.
  • There exists at least one Feng Shui compliant square.
  • There are no repeated points in the list.
# Points Constraints
1 5 Examples.
2 35 1N501 \leq N \leq 50
3 30 1N5001 \leq N \leq 500
4 30 No additional limitations

Example 1

stdin

6
0 10
20 10
10 10
10 0
10 20
0 0

stdout

10

Explanation

In the first sample case, there is only one square aligned with the axes. Another larger square would be possible, but it would not be aligned with the axes.

Example 2

stdin

6
0 0
0 100
100 0
100 100
200 0
200 100

stdout

100

Explanation

In the second sample case there are two possible squares of the same size.

Log in or sign up to be able to send submissions!