In Bob's country, there are cities, numbered from
to
. The
-th city is located at coordinates
on a 2D plane. There are initially
roads connecting the cities in sequence. For each
from
to
, there is a road between city
and city
. The length of this road is defined by the Manhattan distance between the two cities, i.e.
.
A path from city to city
is a sequence of roads that allows people to travel from
to
. The length of a path is the sum of the lengths of the roads in that path. The diameter of the country is defined as the longest shortest path between any two cities.
To reduce the diameter, Bob is allowed to build one additional road between any pair of distinct cities and
(
). The new road's length is also defined by the Manhattan distance between the two cities.
Bob wants to choose the best pair of cities to build this new road such that the resulting diameter of the country is minimized. Can you help him find the shortest diameter?
Input Specification
The first line contains an integer (
), the number of cities.
Each of the following lines contains two integers
,
(
), the coordinates of the
-th city.
Output Specification
Output one integer, the minimum diameter after adding one optimal road.
Constraints
Subtask | Points | Additional constraints |
---|---|---|
No additional constraints |
Sample Input
4
1 2
3 3
4 1
2 3
Sample Output
6
Explanation for Sample
Bob can build the new road between city and city
. The new diameter will be the path from city
to city
with the length of
.
Comments