#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<stdio.h>
using namespace std;

short broiTochki;

short x[2048];
short y[2048];

struct DanniZaSaseda{
    short koiE;
    short razst;
};

vector<DanniZaSaseda> sasedstvo[2048];

struct DanniZaOpashkata{
    short doKoi;
    short razst;

    DanniZaOpashkata(short doKoi, short razst)
        : doKoi(doKoi), razst(razst)
    {

    }
};

struct koiEPonapred{
    bool operator()(DanniZaOpashkata const& a, DanniZaOpashkata const& b)
    {
        return a.razst > b.razst;
    }
};

short naiKasPatOtDo[2048][2048];
bool imameLiNaiKasPat[2048][2048];

priority_queue<DanniZaOpashkata, vector<DanniZaOpashkata>, koiEPonapred> q;

void bfs(short start){
    q.push({start, 0});

    while(q.empty() == false){
        DanniZaOpashkata naiOtpred = q.top();
        q.pop();

        if(imameLiNaiKasPat[start][naiOtpred.doKoi] == true){
            continue;
        }
        naiKasPatOtDo[start][naiOtpred.doKoi] = naiOtpred.razst;
        imameLiNaiKasPat[start][naiOtpred.doKoi] = true;

        for(short i = 0; i < (short)sasedstvo[naiOtpred.doKoi].size(); i++){
            if(imameLiNaiKasPat[start][sasedstvo[naiOtpred.doKoi][i].koiE] == false){
                q.push({sasedstvo[naiOtpred.doKoi][i].koiE, naiOtpred.razst + sasedstvo[naiOtpred.doKoi][i].razst});
            }
        }

    }
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>broiTochki;

    for(short i = 0; i < broiTochki; i++){
        cin>>x[i]>>y[i];
    }

    for(short i = 0; i < broiTochki; i++){
        for(short j = i + 1; j < broiTochki; j++){
            if(x[i] == x[j] || y[i] == y[j]){
                short razst = abs(x[i] - x[j]) + abs(y[i] - y[j]);
                sasedstvo[i].push_back({j, razst});
                sasedstvo[j].push_back({i, razst});
            }
        }
    }

    for(short i = 0; i < broiTochki; i++){
        bfs(i);
    }

    short naiDalgiq = 0;

    for(short i = 0; i < broiTochki; i++){
        for(short j = 0; j < broiTochki; j++){
            naiDalgiq = max(naiDalgiq, naiKasPatOtDo[i][j]);
        }
    }

    cout<<naiDalgiq<<endl;

    return 0;
}
