#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[4][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=3e8;

void rec(int pref,bool type, ll depth,ll prev,ll start,ll lim){
    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[pref][start][curr];
                path[pref][start][curr]=min(path[pref][start][curr],path[pref][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[pref][start][curr])
                    rec(pref,type,depth+1,curr,start,lim);
            }
        }else{
            for(auto curr:x[a[prev]]){
                if(curr==prev)
                    continue;
                ll temp=path[pref][start][curr];
                path[pref][start][curr]=min(path[pref][start][curr],path[pref][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[pref][start][curr])
                    rec(pref,type, depth+1,curr,start,lim);
            }
        }
    }else{
        if(depth%2==0){
            for(auto curr:y[b[prev]]){
                if(curr==prev)
                    continue;
                ll temp=path[pref][start][curr];
                path[pref][start][curr]=min(path[pref][start][curr],path[pref][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[pref][start][curr])
                    rec(pref,type,depth+1,curr,start,lim);
            }
        }else{
            for(auto curr:x[a[prev]]){
                if(curr==prev)
                    continue;
                ll temp=path[pref][start][curr];
                path[pref][start][curr]=min(path[pref][start][curr],path[pref][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[pref][start][curr])
                    rec(pref, type, depth+1,curr,start,lim);
            }
        }
    }
}

void rec2(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[3][start][curr]=min(path[3][start][curr],path[3][start][prev]+abs(a[curr]-a[prev])+abs(b[curr]-b[prev]));
            cycles+=10;
            if(cycles>=1e8)
                return;
            rec2(depth+1,lim,curr,start);
        }
    }else{
        for(auto curr:x[a[prev]]){
            if(curr==prev)
                continue;
            path[4][start][curr]=min(path[4][start][curr],path[4][start][prev]+abs(a[curr]-a[prev])+abs(b[curr]-b[prev]));
            cycles+=10;
            if(cycles>=1e8)
                return;
            rec2(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[0][i][j]=1e18;
            path[1][i][j]=1e18;
            path[2][i][j]=1e18;
            path[3][i][j]=1e18;
            cycles+=2;
            if(i==j){
                path[0][i][j]=1e18;
                path[1][i][j]=0;
                path[2][i][j]=0;
                path[3][i][j]=0;
            }
        }
    }
    for(ll i=0;i<n;i++){
        visited[i]=1;
        rec(1,1,0,i,i,10);
        rec(1,0,0,i,i,10);
        for(ll i=0;i<n;i++){
            visited[i]=0;
        }
    }
    for(ll i=0;i<n;i++){
        visited[i]=1;
        rec(2,1,0,i,i,3);
        rec(2,0,0,i,i,3);
        for(ll i=0;i<n;i++){
            visited[i]=0;
        }
    }
    for(ll i=0;i<n;i++){
        rec2(0,3,i,i);
    }
    /*
    for(ll m=1;m<4;m++){
        for(ll i=0;i<n;i++){
            for(ll j=0;j<n;j++){
                cout<<path[m][i][j]<<" ";
            }
            cout<<endl;
        }
    }
    */
    random_device r;
    default_random_engine e1(r());
    uniform_int_distribution<int> uniform_dist(1, 3);
    ll ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
                if(i==j)
                    continue;
                ll c=0;
                int choice=uniform_dist(e1);
                while(path[choice][i][j]==1e18 and c<10){
                    c++;
                }
                if(c<10)
                    ans=max(ans,path[choice][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
*/
