#include using namespace std; using ll = long long; #define all(p) p.begin(),p.end() #define rep(i,a,b) for(int i=(int)a;i<(int)b;i++) const int mod=998244353; namespace po167{ template struct segment_tree{ int _n,size; std::vector seg; int ceil_pow2(int a){ int b=1; while(a>b){ b<<=1; } return b; } void update(int k){seg[k]=op(seg[k*2],seg[k*2+1]);}; segment_tree(int n) :_n(n){ size=ceil_pow2(n); seg=std::vector(size*2,e()); } segment_tree(std::vector &p) :_n((int) p.size()){ size=ceil_pow2(_n); seg=std::vector(size*2,e()); for(int i=0;i<_n;i++) seg[i+size]=p[i]; for(int i=size-1;i>0;i--) update(i); } void set(int ind,T val){ assert(0<=ind&&ind<_n); ind+=size; seg[ind]=val; while(ind!=1){ ind>>=1; update(ind); } } void addl(int ind,T val){ set(ind,op(get(ind),val)); } void addr(int ind,T val){ set(ind,op(val,get(ind))); } T get(int ind){ assert(0<=ind&&ind<_n); return seg[ind+size]; } T query(int l,int r){ assert(0<=l&&l<=r&&r<=_n); T l_val=e(); T r_val=e(); l+=size,r+=size; while(l>=1; l>>=1; } return op(l_val,r_val); } template int max_right(int l) { return max_right(l, [](T x) { return f(x); }); } template int max_right(int l, F f) { assert(0<=l&&l<=_n); assert(f(e())); if(f(query(l,_n))) return _n; T val=e(); l+=size; while(true){ while(l%2==0) l>>=1; if(!f(op(val,seg[l]))){ while(l int min_left(int r) { return min_left(r, [](T x) { return f(x); }); } template int min_left(int r, F f) { assert(0 <= r && r <= _n); assert(f(e())); if (r == 0) return 0; r += size; T sm = e(); do { r--; while (r > 1 && (r % 2)) r >>= 1; if (!f(op(seg[r], sm))) { while (r < size) { r = (2 * r + 1); if (f(op(seg[r], sm))) { sm = op(seg[r], sm); r--; } } return r + 1 - size; } sm = op(seg[r], sm); } while ((r & -r) != r); return 0; } }; } using po167::segment_tree; using F= int; F op(F a,F b){return max(a,b);} F e(){return -100000000;} int main(){ int N; cin>>N; vector X(N),Y(N); rep(i,0,N) cin>>X[i]>>Y[i]; vector A(N),B(N),P(N),Q(N,N*2+10); rep(i,0,N) A[i]=X[i]+Y[i],B[i]=X[i]-Y[i]; sort(all(A)),sort(all(B)); rep(i,0,N){ int a=X[i]+Y[i]; int b=X[i]-Y[i]; P[i]=max(max(A[N-1]-a,a-A[0]),max(B[N-1]-b,b-B[0])); } rep(k,0,4){ rep(i,0,N) X[i]=N+1-X[i]; if(k&1) rep(i,0,N) Y[i]=N+1-Y[i]; vector order(N); rep(i,0,N) order[i]=i; sort(all(order),[&](int l,int r){ if(X[l]==X[r]) return Y[l] seg(N+3); rep(i,0,N){ int a=order[i]; int val=X[a]+Y[a]; Q[a]=min(Q[a],val-seg.query(0,Y[a]+1)); seg.set(Y[a],val); } } int ans=N*2; //rep(i,0,N) cout<