Problem:
Score : 500 points

Problem Statement

There are N points on the 2D plane, i-th of which is located on (x_i, y_i).
There can be multiple points that share the same coordinate.
What is the maximum possible Manhattan distance between two distinct points?

Here, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.

Constraints

2 \leq N \leq 2 \times 10^5

1 \leq x_i,y_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
x_2 y_2
:
x_N y_N

Output

Print the answer.

Sample Input 1

3
1 1
2 4
3 2

Sample Output 1

4

The Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.

Sample Input 2

2
1 1
1 1

Sample Output 2

0

Solution in Ruby (2.7.1) (judge verdict: Accepted)

n = gets.chomp.to_i
arr = n.times.map{gets.chomp.split(" ").map(&:to_i)}

MAX = 10 ** 10

min_x = MAX
min_y = MAX
max_x = 0
max_y = 0
arr.each do |(x, y)|
  min_x = x if x < min_x
  max_x = x if x > max_x
  min_y = y if y < min_y
  max_y = y if y > max_y
end

min1 = MAX
min2 = MAX
min3 = MAX
min4 = MAX
p_arr = [nil, nil, nil, nil]
arr.each do |(x, y)|
  tmp = (x - min_x).abs + (y - min_y).abs
  if tmp < min1
    p_arr[0] = [x, y]
    min1 = tmp
  end
  tmp = (x - min_x).abs + (y - max_y).abs
  if tmp < min2
    p_arr[1] = [x, y]
    min2 = tmp
  end
  tmp = (x - max_x).abs + (y - min_y).abs
  if tmp < min3
    p_arr[2] = [x, y]
    min3 = tmp
  end
  tmp = (x - max_x).abs + (y - max_y).abs
  if tmp < min4
    p_arr[3] = [x, y]
    min4 = tmp
  end
end

max = 0
p_arr.each do |(x1, y1)|
  p_arr.each do |(x2, y2)|
    tmp = (x1 - x2).abs + (y1 - y2).abs
    max = tmp if tmp > max
  end
end
puts max