#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x[n], y[n], sum = 0;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  for (int i = 0; i < n - 1; i++) {
    sum += min(fabs(x[i] - x[i + 1]), fabs(y[i] - y[i + 1]));
  }
  cout << sum;
}
