#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;
/*
void dijkstra(ll start_node){
    while(!best.empty()){
        pair<ll,ll> curr_node=*best.begin();
        while(visited[curr_node.second]){
            best.erase(curr_node);
            curr_node=*best.begin();
        }
        best.erase(curr_node);
        if(curr_node.first==1e18)
            break;
        path[start_node][curr_node.second]=curr_node.first;
        visited[curr_node.second]=1;
        for(ll i=0;i<adj[curr_node.second].size();i++){
            pair<ll,ll> next_node=adj[curr_node.second][i];
            best.erase({path[start_node][next_node.first],next_node.second});
            path[start_node][next_node.first]=min(path[start_node][next_node.first],path[start_node][curr_node.second]+next_node.second);
            best.insert({path[start_node][next_node.first],next_node.second});
        }

    }
}
*/

void rec(ll depth,ll lim,ll prev,ll start){
    if(depth==lim)
        return;
    if(depth%2!=0){
        for(auto curr:y[b[prev]]){
            if(curr==prev)
                continue;
            path[start][curr]=min(path[start][curr],path[start][prev]+abs(a[curr]-a[prev])+abs(b[curr]-b[prev]));
            cycles+=10;
            if(cycles>=1e8)
                return;
            rec(depth+1,lim,curr,start);
        }
    }else{
        for(auto curr:x[a[prev]]){
            if(curr==prev)
                continue;
            path[start][curr]=min(path[start][curr],path[start][prev]+abs(a[curr]-a[prev])+abs(b[curr]-b[prev]));
            cycles+=10;
            if(cycles>=1e8)
                return;
            rec(depth+1,lim,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]=1e18;
            cycles+=2;
            if(i==j)
                path[i][j]=0;
        }
    }
    for(ll i=0;i<n;i++){
        rec(0,3,i,i);
    }
    /*
    for(ll i=0;i<n;i++){
        best.clear();
        for(ll j=0;j<n;j++){
            if(j==i){
                best.insert({0,j});
            }else{
                best.insert({1e18,j});
            }
        }
        dijkstra(i);
    }

    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]!=1e18){
                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;
}
