using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3");
WillReturn.Add("0 0");
WillReturn.Add("1 3");
WillReturn.Add("5 6");
//3
}
else if (InputPattern == "Input2") {
WillReturn.Add("5");
WillReturn.Add("0 5");
WillReturn.Add("1 7");
WillReturn.Add("2 9");
WillReturn.Add("3 8");
WillReturn.Add("4 6");
//11
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
class XYInfoDef
{
internal long X;
internal long Y;
}
static void Main()
{
List<string> InputList = GetInputList();
long[] wkArr = { };
Action<string> SplitAct = pStr =>
wkArr = pStr.Split(' ').Select(pX => long.Parse(pX)).ToArray();
var OddList = new List<XYInfoDef>();
var EvenList = new List<XYInfoDef>();
foreach (string EachStr in InputList.Skip(1)) {
SplitAct(EachStr);
long X = wkArr[0];
long Y = wkArr[1];
var WillAdd = new XYInfoDef();
WillAdd.X = X;
WillAdd.Y = Y;
if ((X + Y) % 2 == 1) {
OddList.Add(WillAdd);
}
else {
EvenList.Add(WillAdd);
}
}
long SumOdd = 0;
long SumEven = 0;
if (OddList.Count >= 2) {
SumOdd = Solve(OddList.ToArray());
}
if (EvenList.Count >= 2) {
SumEven = Solve(EvenList.ToArray());
}
Console.WriteLine(SumOdd + SumEven);
}
static long Solve(XYInfoDef[] pXYInfoArr)
{
long UB = pXYInfoArr.GetUpperBound(0);
// 45度回転する
for (long I = 0; I <= UB; I++) {
long X = pXYInfoArr[I].X;
long Y = pXYInfoArr[I].Y;
pXYInfoArr[I].X = X - Y;
pXYInfoArr[I].Y = X + Y;
}
long[] XArr = pXYInfoArr.Select(pX => pX.X).ToArray();
long[] YArr = pXYInfoArr.Select(pX => pX.Y).ToArray();
Array.Sort(XArr);
Array.Sort(YArr);
var InsFenwick_Tree_X = new Fenwick_Tree(XArr);
var InsFenwick_Tree_Y = new Fenwick_Tree(YArr);
long Answer = 0;
for (long I = 0; I <= UB - 1; I++) {
long RangeSta = I + 1;
long RangeEnd = UB;
long RangeLen = RangeEnd - RangeSta + 1;
Answer += InsFenwick_Tree_X.GetSum(RangeSta, RangeEnd);
Answer += InsFenwick_Tree_Y.GetSum(RangeSta, RangeEnd);
Answer -= XArr[I] * RangeLen;
Answer -= YArr[I] * RangeLen;
}
// (45回転後のマンハッタン距離 / 2) = 45回転前のチェス盤距離
return Answer / 2;
}
}
// フェニック木
#region Fenwick_Tree
internal class Fenwick_Tree
{
private long[] mBitArr;
private long mExternalArrUB;
// ノードのIndexの列挙を返す
internal IEnumerable<long> GetNodeIndEnum()
{
for (long I = 0; I <= mExternalArrUB; I++) {
yield return I;
}
}
// 木のノードのUBを返す
internal long GetUB()
{
return mExternalArrUB;
}
// コンストラクタ(外部配列のUBのみ指定)
internal Fenwick_Tree(long pExternalArrUB)
{
mExternalArrUB = pExternalArrUB;
// フェニック木の外部配列は0オリジンで、
// フェニック木の内部配列は1オリジンなため、2を足す
mBitArr = new long[pExternalArrUB + 2];
}
// コンストラクタ(初期化用の配列指定)
internal Fenwick_Tree(long[] pArr)
: this(pArr.GetUpperBound(0))
{
for (long I = 0; I <= pArr.GetUpperBound(0); I++) {
this.Add(I, pArr[I]);
}
}
// コンストラクタ(初期化用のList指定)
internal Fenwick_Tree(List<long> pList)
: this(pList.Count - 1)
{
for (int I = 0; I <= pList.Count - 1; I++) {
this.Add(I, pList[I]);
}
}
// [pSta,pEnd] のSumを返す
internal long GetSum(long pSta, long pEnd)
{
return GetSum(pEnd) - GetSum(pSta - 1);
}
// [0,pEnd] のSumを返す
internal long GetSum(long pEnd)
{
pEnd++; // 1オリジンに変更
long Sum = 0;
while (pEnd >= 1) {
Sum += mBitArr[pEnd];
pEnd -= pEnd & -pEnd;
}
return Sum;
}
// [I] に Xを加算
internal void Add(long pI, long pX)
{
pI++; // 1オリジンに変更
while (pI <= mBitArr.GetUpperBound(0)) {
mBitArr[pI] += pX;
pI += pI & -pI;
}
}
}
#endregion