#include <bits/stdc++.h>
#define endl "\n"
#pragma GCC optimize("Ofast")
using namespace std;
const int mod = 1e9 + 7;

const int MAX_N = 2e3 + 10;
vector<int> whox[MAX_N], whoy[MAX_N];
int x[MAX_N], y[MAX_N];
int n;
int dist[MAX_N];
int ans = 0;
int passes[MAX_N];
int cntx[MAX_N], cnty[MAX_N];

int mv(int a, int b) {
    return abs(x[a] - x[b]) + abs(y[a] - y[b]);
}

void dij(int st) {
    for(int i = 0; i < n; i ++) {
        dist[i] = mod;
        passes[i] = false;
    }
    for(int i = 0; i < MAX_N; i ++) {
        cntx[i] = 5;
        cnty[i] = 5;
    }
    priority_queue<pair<int, int> > pq;
    dist[st] = 0;
    pq.push({dist[st], st});

    while(!pq.empty()) {
        auto curr = pq.top(); pq.pop();
        curr.first *= -1;
        if(passes[curr.second]) { continue; }
        passes[curr.second] = true;

        if(cntx[curr.second] > 0) for(const auto it : whox[x[curr.second]]) {
            if(dist[it] > curr.first + abs(y[curr.second] - y[it])) {
                dist[it] = curr.first + abs(y[curr.second] - y[it]);
                pq.push({-dist[it], it});
            }
        }
        cntx[curr.second] --;

        if(cnty[curr.second] > 0)for(const auto it : whoy[y[curr.second]]) {
            if(dist[it] > curr.first + abs(x[curr.second] - x[it])) {
                dist[it] = curr.first + abs(x[curr.second] - x[it]);
                pq.push({-dist[it], it});
            }
        }
        cnty[curr.second] --;
    }

    for(int i = 0; i < n; i ++) {
        if(dist[i] == mod) { continue; }
        ans = max(ans, dist[i]);
    }
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    cin >> n;
    for(int i = 0; i < n; i ++) {
        cin >> x[i] >> y[i];
        whox[x[i]].push_back(i);
        whoy[y[i]].push_back(i);
    }


    for(int i = 0; i < n; i ++) {
        dij(i);
    }
    cout << ans << endl;

    return 0;
}
