#include <iostream>
#include <vector>
#include <cmath>
#include <climits>
#include <algorithm>
#define MAX_N 2000
using namespace std;

struct Point
{
    int a;
    int b;
    vector<pair<int, int>> susedi;
} ;

vector <Point> tochki;
int dist[MAX_N];
bool visited[MAX_N];
void deikstra(int start, int n)
{
    int mini;
    int j;
    fill_n(dist, n, INT_MAX);
    fill_n(visited, n, false);
    for(int i=0; i<tochki[start].susedi.size(); i++)
    {
        dist[tochki[start].susedi[i].first]=tochki[start].susedi[i].second;
    }
    visited[start]=true;
    while(true)
    {
        mini=INT_MAX;
        j=-1;
        for(int i=0; i<n; i++)
        {
            if(mini<dist[i])
            {
                mini=dist[i];
                j=i;
            }
        }
        if(j==-1 || mini==INT_MAX)
        {
            break;
        }
        visited[j]=true;
        for(int i=0; i<tochki[j].susedi.size(); i++)
        {
            if(!visited[tochki[j].susedi[i].first])
            {
                if(tochki[j].susedi[i].second+mini<dist[tochki[j].susedi[i].first])
                {
                    dist[tochki[j].susedi[i].first]=tochki[j].susedi[i].second+mini;
                }
            }
        }
    }


}


int main()
{
    int n;
    cin >> n;
    tochki.resize(n);
    int x, y;
    int r;
    for(int i=0; i<n; i++)
    {
        cin >> x >> y;
        tochki[i].a=x;
        tochki[i].b=y;
        for(int j=0; j<i; j++)
        {
            if(tochki[j].a==x)
            {
                r=max(tochki[j].b,y)-min(tochki[j].b, y) + max(tochki[j].a, c)-min(tochki[j].a, c);
                tochki[j].susedi.push_back({i, r});
                tochki[i].susedi.push_back({j, r});
            }
            else if(tochki[j].b==y)
            {
                r=max(tochki[j].a, x)-min(tochki[j].a, x) + max(tochki[j].b,y)-min(tochki[j].b, y);
                tochki[j].susedi.push_back({i, r});
                tochki[i].susedi.push_back({j, r});
            }
        }
    }
    int currMax=0;

    for(int i=0; i<n; i++)
    {
        deikstra(i, n);
        for(int j=0; j<n; j++)
        {
            if(dist[j]!=INT_MAX && dist[j]>currMax)
            {
                currMax=dist[j];
            }
        }
    }

    cout << currMax;



    return 0;
}
