#include <bits/stdc++.h>
using namespace std;

int n, x[2004], y[2004], ans;
vector <pair <int, int> > nbs[2004];
int path[2004][2004];
const int inf = -1000000000;

void dijkstra (int a) {
    path[a][a] = 0;
    //bool used[2004];
    //for (int i=0; i < n; i++) {used[i] = false;}
    //used[a] = true;
    priority_queue <pair <int, int> > q;
    q.push({a, 0});
    while (q.empty() == false) {
        int curr = q.top().second, curr_path = q.top().first;
        q.pop();
        for (int i=0; i < nbs[curr].size(); i++) {
            int currn = nbs[curr][i].first, currp = (-1)*nbs[curr][i].second;
            //if (used[currn] == false) {
                //used[currn] = true;
                if (path[a][currn] == inf or path[a][currn] < curr_path + currp) {
                    path[a][currn] = curr_path + currp;
                    q.push({currn, path[a][currn]});
                }
            //}
        }
    }
}

int main () {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

cin >> n;

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

for (int i=0; i < n; i++) {
    for (int j=i; j < n; j++) {
        if (x[i] == x[j] or y[i] == y[j]) {
            nbs[i].push_back({j, abs(x[i]-x[j]) + abs(y[i]-y[j])});
            nbs[j].push_back({i, abs(x[i]-x[j]) + abs(y[i]-y[j])});
        }
    }
}

for (int i=0; i < n; i++) {
    for (int j=0; j < n; j++) {
        path[i][j] = inf;
    }
}

for (int i=0; i < n; i++) {
    dijkstra(i);
}

ans = inf;

for (int i=0; i < n; i++) {
    for (int j=i; j < n; j++) {
        if (path[i][j] != inf) {path[i][j] = abs(path[i][j]);}
        //cout << i << " " << j << " " << path[i][j] << endl;
        ans = max (ans, path[i][j]);
    }
}

cout << 0 << endl;

return 0;
}