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 Go (1.14.1) (judge verdict: Wrong Answer)

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func max(a ...int) int {
	m := a[0]
	for i, v := range a {
		if i == 0 {
			continue
		}
		if m < v {
			m = v
		}
	}
	return m
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for E - Dist Max
	var N int
	fmt.Scan(&N)

	sc.Split(bufio.ScanWords)
	x := make([]int, N)
	y := make([]int, N)

	var z1, z2 int

	var Max1 int
	//var MaxNum1 int
	var Min1 int = 100000000000
	//var MinNum1 int

	var Max2 int
	//var MaxNum2 int
	var Min2 int = 100000000000
	//var MinNum2 int

	for i := 0; i < N; i++ {
		x[i] = nextInt()
		y[i] = nextInt()

		z1 = x[i] - y[i]
		z2 = x[i] + y[i]

		if Max1 < z1 {
			Max1 = z1
			//MaxNum1 = i
		}

		if Min1 > z1 {
			Min1 = z1
			//MinNum1 = i
		}

		if Max2 < z2 {
			Max2 = z2
			//MaxNum2 = i
		}

		if Min2 > z2 {
			Min2 = z2
			//MinNum2 = i
		}
	}

	var ans, ans1, ans2 int //, ans3, ans4 int
	for i := 0; i < N; i++ {
		//ans1 = int(math.Abs(float64(x[MaxNum1]-x[i]))) + int(math.Abs(float64(y[MaxNum1]-y[i])))
		//ans2 = int(math.Abs(float64(x[MinNum1]-x[i]))) + int(math.Abs(float64(y[MinNum1]-y[i])))
		//ans3 = int(math.Abs(float64(x[MaxNum2]-x[i]))) + int(math.Abs(float64(y[MaxNum2]-y[i])))
		//ans4 = int(math.Abs(float64(x[MinNum2]-x[i]))) + int(math.Abs(float64(y[MinNum2]-y[i])))
		ans1 = Max1 - Min1
		ans2 = Max2 - Min2
		ans = max(ans, ans1, ans2) //, ans3, ans4)
	}

	fmt.Println(ans)
}