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 C# (Mono-mcs 6.8.0.105) (judge verdict: Wrong Answer)

using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;


class Program
{
	public struct Coord : IComparable<Coord>
	{
		public long X;
		public long Y;
		public long dist;

		//コンストラクタ
		public Coord(long x, long y)
		{
			this.X = x;
			this.Y = y;
			this.dist = x + y;
		}

		//比較方法の定義（CompareToメソッド）
		/*
		別のインスタンスとの比較方法を定義。
		this > other の場合には1を、（この場合、昇順ソートすると other, this）
		this = other の場合には0を、
		this < other の場合には-1を、（この場合、昇順ソートすると this, other）
		それぞれ返すようにする。（intで吐き出す）
		*/
		public int CompareTo(Coord other)
		{
			return this.dist.CompareTo(other.dist);
		}
	}

	//Main
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());

		int lim = 3000;

		Coord[] arr = new Coord[N];
		for(int i=0; i<N; i++){
			long[] xy = Console.ReadLine().Split(' ').Select(j => long.Parse(j)).ToArray();
			Coord c = new Coord(xy[0], xy[1]);
			arr[i] = c;
		}

		Array.Sort(arr);

		long ans = 0;

		for(int i=0; i<Math.Min(N,lim); i++){
			for(int k=0; k<Math.Min(N,lim); k++){
				int j = N - k - 1;
				long d = Math.Abs(arr[i].X - arr[j].X) + Math.Abs(arr[i].Y - arr[j].Y);
				if(d > ans){
					ans = d;
				}
			}
		}

		Console.WriteLine(ans);
	}
}