#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
	template <class Arg1, class... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* sep = strchr(names + 1, ',');
		cerr.write(names, sep - names) << " : " << arg1 << "  ";
		__f(sep + 1, args...);
	}
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<char,int> pci;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
 


#define pb push_back
 
// order_of_key (k), find_by_order(k)
#define fi first
#define se second
#define input_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
#define initialise(a, x) memset(a, x, sizeof(a))
#define endl '\n'
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX 1000020
#define maxn 200005
#define eps 0.0000001

const ll mod=1e9+7;
const ll inf=1e18+2;

#define int ll

int n;
std::vector<int> a;


ll seg[4*maxn];
ll lazy[4*maxn];

void build(int l,int h,int pos)
{
	if(l==h)
	{
		seg[pos]=a[l];return;
	}
	int m=(l+h)/2;
	build(l,m,2*pos+1);
	build(m+1,h,2*pos+2);
	seg[pos]=max(seg[2*pos+1],seg[2*pos+2]);
}

void update(int l,int h,int pos,int ql,int qh,ll val)
{
	seg[pos]+=lazy[pos];
	if(l!=h)
	{
		lazy[2*pos+1]+=lazy[pos];
		lazy[2*pos+2]+=lazy[pos];
	}
	lazy[pos]=0;

	if(qh<l || ql>h) return;
	if(l>=ql and h<=qh)
	{
		seg[pos]+=val;
		if(l!=h)
		{
			lazy[2*pos+1]+=val;
			lazy[2*pos+2]+=val;
		}
		return;
	}
	int m=(l+h)/2;

	update(l,m,2*pos+1,ql,qh,val);
	update(m+1,h,2*pos+2,ql,qh,val);

	seg[pos]=max(seg[2*pos+1],seg[2*pos+2]);
}

ll query(int l,int h,int pos,int ql,int qh)
{
	seg[pos]+=lazy[pos];
	if(l!=h)
	{
		lazy[2*pos+1]+=lazy[pos];
		lazy[2*pos+2]+=lazy[pos];
	}
	lazy[pos]=0;

	if(qh<l || ql>h) return 0;
	if(l>=ql and h<=qh) return seg[pos];

	int m=(l+h)/2;
	return max(query(l,m,2*pos+1,ql,qh),query(m+1,h,2*pos+2,ql,qh));
}




signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	// freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);


	cin>>n;

	map<int,int> mx,mn;

	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		if(mx.find(x)!=mx.end())
		{
			mx[x]=max(mx[x],y);
			mn[x]=min(mn[x],y);
		}
		else
		{
			mx[x]=y;
			mn[x]=y;
		}
	}

	int ans=-inf;

	for(auto h:mx)
	{
		ans=max(ans,abs(h.se-mn[h.fi]));
	}

	n=mx.size();

	int first=(*mn.begin()).fi;

	for(auto h:mx)
	{
		a.pb(h.se+(h.fi-first));
	}

	build(0,n-1,0);

	int indx=0;

	auto it=mx.end();
	it--;

	for(auto h:mn)
	{
		if(h.fi==(*it).fi)
		{
			int my=h.se;
			int mxy=query(0,n-1,0,0,n-1);

			ans=max(ans,abs(my-mxy));
		}
		else
		{
			int my=h.se;

			auto itl=mn.find(h.fi);
			auto itr=itl;
			itr++;

			int diff=(*itr).fi-(*itl).fi;

			int mxy=query(0,n-1,0,0,n-1);

			ans=max(ans,abs(my-mxy));

			update(0,n-1,0,indx+1,n-1,-diff);
			update(0,n-1,0,0,indx,diff);
			indx++;
		}
	}


	cout<<ans<<'\n';





	
	



	


	return 0;
}

Measured memory_bytes: 38240