cho.sh
Notes
Loading...

Covering Points with a Square

Time limit

2s

Memory limit

128 MB

Problem

A point is considered covered by a square when it lies on one of the square's four side segments.

You are given N distinct points. Determine whether there is a square that covers every point, and if so, find its side length. The sides of the square must be parallel to the x-axis or y-axis.

Input

The first line contains N. Each of the next N lines contains two integers, the X-coordinate and Y-coordinate of one point. The absolute value of every coordinate is at most 1000. All coordinates are integers, and no point appears more than once.

Output

If there exists a square that can cover every point, print the side length of that square on the first line. Otherwise, print -1.

Constraints

  • 2 ≤ N ≤ 50