eolymp
bolt
Try our new interface for solving problems

Fence

Emos have relocated to newly built houses and decided to build a fence around their settlement. Emos are strange people, and they will cry if at least one section of the fence is not parallel to coordinate axis. Therefore, you have a task -- to build a fence of minimal length around Emo's settlement in a way that all houses are located inside the area limited by the fence. The fence should be a polygon without self-intersections and self-tangencies with sides parallel to coordinate axis. Houses are points having coordinates. Some houses are allowed to be located at the fence itself. \InputFile The first line contains integer \textbf{n} (\textbf{2} ≤ \textbf{n} ≤ \textbf{100 000}) -- number of houses. The following \textbf{n} lines contain descriptions of houses -- each line contains two integers \textbf{x_i}, \textbf{y_i} (\textbf{-10^9} ≤ \textbf{x_i}, \textbf{y_i} ≤ \textbf{10^9}). All houses are located at different points, at least two \textbf{x}-coordinates and \textbf{y}-coordinates are different. \OutputFile You need to print one integer -- the minimal possible length of the fence.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4
1 0
0 1
1 1
0 0
Output example #1
4
Source 2014 ACM-ICPC Ukraine, 2nd Round Ukraine, September 13, Problem J