using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static long[] compressedX;//[i]は、iに圧縮前の座標
static long[] compressedY;

	static void Main()
	{
		long n = long.Parse(Console.ReadLine());
    long[,] vertexes = new long[n*2,3];//x,y座標と順番
    for(long i = 0; i < n; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      vertexes[i,0] = nums[0];
      vertexes[i,1] = nums[1];
      vertexes[i,2] = i;
      vertexes[n+i,0] = nums[2];
      vertexes[n+i,1] = nums[3];
      vertexes[n+i,2] = n+i;
    }
    long[,] compressedVertexes = CoordinateCompression(vertexes);//座標圧縮

    long[,] area = new long[4001,4001];//シールを貼った部分
    long answer = 0;
 
    for(long i = 0; i < n; i++)
    {
      area[compressedVertexes[i,3],compressedVertexes[i,4]]++;
      area[compressedVertexes[i,3],compressedVertexes[n+i,4]]--;
      area[compressedVertexes[n+i,3],compressedVertexes[i,4]]--;
      area[compressedVertexes[n+i,3],compressedVertexes[n+i,4]]++;
    }
 
    for(long x = 1; x <= 4000; x++)
    {
      for(long y = 0; y <= 4000; y++)
      {
        area[x,y] += area[x-1,y];
      }
    }
 
    for(long y = 1; y <= 4000; y++)
    {
      for(long x = 0; x <= 4000; x++)
      {
        area[x,y] += area[x,y-1];
      }
    }
     
    for(long x = 0; x <= 4000; x++)
    {
      for(long y = 0; y <= 4000; y++)
      {
        if(area[x,y] >= 1)//長方形に囲まれているならば
        {
          answer += (compressedX[x+1]-compressedX[x]) * (compressedY[y+1]-compressedY[y]);
        }
      }
    }
 
    Console.WriteLine(answer);
	}

  static long[,] CoordinateCompression(long[,] vertexesOriginal)
    //2次元の座標圧縮。配列は0-indexで[x,y,順番]。compressedX,Yも更新。
  {
    long n = vertexesOriginal.GetLength(0);//多次元配列の長さの取得
    long xCount = 1;//圧縮後のxの個数
    long yCount = 1;
    long[] compressedXmemo = new long[n];
    long[] compressedYmemo = new long[n];
    long[][] vertexes = new long[n][];
    for(long i = 0; i < n; i++)
    {
      vertexes[i] = new long[5];
      for(long j = 0; j < 3; j++)
      {
        vertexes[i][j] = vertexesOriginal[i,j];//配列をジャグ配列に置換
      }
    }

    Array.Sort(vertexes, (a, b) => a[0].CompareTo(b[0]));//x座標でソート
    vertexes[0][3] = 0;
    compressedXmemo[0] = vertexes[0][0];
    for(long i = 1; i < n; i++)
    {
      if(vertexes[i][0] == vertexes[i-1][0])//x座標が同じ
      {
        vertexes[i][3] = xCount - 1;
      }else
      {
        xCount++;
        vertexes[i][3] = xCount - 1;
        compressedXmemo[xCount-1] = vertexes[i][0];
      }
    }
    compressedX = new long[xCount];
    for(long i = 0; i < xCount; i++) compressedX[i] = compressedXmemo[i];

    Array.Sort(vertexes, (a, b) => a[1].CompareTo(b[1]));//y座標でソート
    vertexes[0][4] = 0;
    compressedYmemo[0] = vertexes[0][1];
    for(long i = 1; i < n; i++)
    {
      if(vertexes[i][1] == vertexes[i-1][1])//y座標が同じ
      {
        vertexes[i][4] = yCount - 1;
      }else
      {
        yCount++;
        vertexes[i][4] = yCount - 1;
        compressedYmemo[yCount-1] = vertexes[i][1];
      }
    }
    compressedY = new long[yCount];
    for(long i = 0; i < yCount; i++) compressedY[i] = compressedYmemo[i];

    Array.Sort(vertexes, (a, b) => a[2].CompareTo(b[2]));//もとの番号順でソート

    long[,] answer = new long[n,5];
    for(long i = 0; i < n; i++)
    {
      for(long j = 0; j < 5; j++)
      {
        answer[i,j] = vertexes[i][j];//ジャグ配列から戻す
      }
    }
    
    return answer;//[x,y,順番,圧縮x,圧縮y]を返す。
  }
  
}


Measured memory_bytes: 142964