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 Java (OpenJDK 11.0.6) (judge verdict: Wrong Answer)

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	static Scanner sc;
	static PrintWriter out;
	static ArrayList<Edge> adj[];
	static int V,E;
	static int[] dist;
	static int[] parent;
	static final int oo = (int) 1e9;
	static final long mod = (long) (1e9 + 7);
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int []dist = new int[n];
		for (int i = 0; i < n; i++) {
			dist[i] = sc.nextInt()+sc.nextInt();
		}
		out.println(max(dist)-min(dist));
		out.close();
	}
	static int min(int []a) {
		int min = oo;
		for (int i : a) {
			min = Math.min(min, i);
		}
		return min;
	}
	static int max(int []a) {
		int max = 0;
		for (int i : a) {
			max = Math.max(max, i);
		}
		return max;
	}
	static void dijkstra(int src) {
		dist = new int[V];
		Arrays.fill(dist, oo);
		parent = new int[V];
		Arrays.fill(parent, -1);
		dist[src] = 0;
		PriorityQueue<Edge> pq = new PriorityQueue<>();
		pq.add(new Edge(src,0));
		while(!pq.isEmpty()) {
			Edge e = pq.poll();
			if(dist[e.x] < e.y)
				continue;
//			if(e.x == dest)
//				return e.y;
			for(Edge e2:adj[e.x]) {
				if(dist[e2.x] > e2.y+e.y) {
					pq.add(new Edge(e2.x,dist[e2.x] = e2.y+e.y));
					parent[e2.x] = e.x;
				}
			}
		}
//		return -1;
	}
	static class Edge extends java.awt.Point implements Comparable<Edge>{		
		public Edge(int u, int val) {
			// TODO Auto-generated constructor stub
			super(u, val);
		}

		@Override
		public int compareTo(Edge e) {
			// TODO Auto-generated method stub
			return y - e.y;
		}		
	}
	static class Scanner{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		private String next() throws Exception{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws Exception{
			return Integer.parseInt(next());
		}
		public long nextLong() throws Exception{
			return Long.parseLong(next());
		}
		public double nextDouble() throws Exception{
			return Double.parseDouble(next());
		}
		public String nextLine() throws Exception {
			return br.readLine();
		}

	}
}