#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll Size=2e3+1;
ll a[Size],b[Size];
ll path[Size][Size];
vector<pair<ll,ll>> adj[Size];
bool visited[Size];
set<ll> x[Size],y[Size];
set<pair<ll,ll>> best;
ll cycles=0, cycle_lim=1e10, lim=2;

void rec(bool type, ll depth,ll prev,ll start){
    visited[prev]=1;
    if(depth==lim)
        return;
    if(type==1){
        if(depth%2!=0){
            for(auto curr:y[b[prev]]){
                if(curr==prev)
                    continue;
                ll temp=path[start][curr];
                path[start][curr]=min(path[start][curr],path[start][prev]+abs(a[curr]-a[prev])+abs(b[curr]-b[prev]));
                cycles+=10;
                if(cycles>=cycle_lim)
                    return;
                if(!visited[curr] or temp>path[start][curr])
                    rec(type,depth+1,curr,start);
            }
        }else{
            for(auto curr:x[a[prev]]){
                if(curr==prev)
                    continue;
                ll temp=path[start][curr];
                path[start][curr]=min(path[start][curr],path[start][prev]+abs(a[curr]-a[prev])+abs(b[curr]-b[prev]));
                cycles+=10;
                if(cycles>=cycle_lim)
                    return;
                if(!visited[curr] or temp>path[start][curr])
                    rec(type, depth+1,curr,start);
            }
        }
    }else{
        if(depth%2==0){
            for(auto curr:y[b[prev]]){
                if(curr==prev)
                    continue;
                ll temp=path[start][curr];
                path[start][curr]=min(path[start][curr],path[start][prev]+abs(a[curr]-a[prev])+abs(b[curr]-b[prev]));
                cycles+=10;
                if(cycles>=cycle_lim)
                    return;
                if(!visited[curr] or temp>path[start][curr])
                    rec(type,depth+1,curr,start);
            }
        }else{
            for(auto curr:x[a[prev]]){
                if(curr==prev)
                    continue;
                ll temp=path[start][curr];
                path[start][curr]=min(path[start][curr],path[start][prev]+abs(a[curr]-a[prev])+abs(b[curr]-b[prev]));
                cycles+=10;
                if(cycles>=cycle_lim)
                    return;
                if(!visited[curr] or temp>path[start][curr])
                    rec(type,depth+1,curr,start);
            }
        }
    }
}
void solve(){
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i]>>b[i];
        x[a[i]].insert(i);
        y[b[i]].insert(i);
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            path[i][j]=9;
            cycles+=2;
            if(i==j)
                path[i][j]=0;
        }
    }
    for(ll i=0;i<n;i++){
        visited[i]=1;
        rec(1,0,i,i);
        rec(0,0,i,i);
        for(ll i=0;i<n;i++){
            visited[i]=0;
        }
    }
    /*
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            cout<<path[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    ll ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            if(path[i][j]!=9){
                ans=max(ans,path[i][j]);
            }
            cycles+=2;
        }
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    while(t--){
        solve();
    }
    return 0;
}
/*
5
0 0
1 0
1 1
1 2
2 2
*/
