using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	static Za2 z;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var h=new int[n][];
		for(int i = 0;i<n;i++) {
			var e=sc.Ia;
			h[i]=new int[]{e[0],e[1],e[2]-1,e[3]-1};
		}
		z=new Za2(h);

		var b=new int[z.my+1][];
		for(int i = 0;i<=z.my;i++) {
			b[i]=new int[z.mx+1];
		}
		for(int i = 0;i<n;i++) {
			int ey=z.Qy(h[i][0]),ex=z.Qx(h[i][1]);
			int fy=z.Qy(h[i][2])+1,fx=z.Qx(h[i][3])+1;
			b[ey][ex]+=1;
			b[ey][fx]+=-1;
			b[fy][ex]+=-1;
			b[fy][fx]+=1;
		}
		long ans=0;
		for(int i = 0;i<z.my;i++) {
			for(int j = 0;j<z.mx;j++) {
				b[i][j+1]+=b[i][j];
			}
		}
		for(int j = 0;j<z.mx;j++) {
			for(int i = 0;i<z.my;i++) {
				b[i+1][j]+=b[i][j];
				if(b[i][j]>0){
					ans+=(long)z.yc[i]*z.xc[j];
				}
			}
		}
		Console.WriteLine(ans);
	}
}
public class Za2{
	public int my,mx;
	private int[] ya,xa;
	private int[] yb,xb;
	public int[] yc,xc;
	public Za2(int[][] a){
		int n=a.Length<<1;
		ya=new int[n];
		xa=new int[n];
		for(int i = 0;i<a.Length;i++) {
			ya[i<<1]=a[i][0]<<1;
			xa[i<<1]=a[i][1]<<1;
			ya[(i<<1)+1]=(a[i][2]<<1)+1;
			xa[(i<<1)+1]=(a[i][3]<<1)+1;
		}
		Array.Sort(ya);
		Array.Sort(xa);
		yb=new int[n];
		xb=new int[n];
		yc=new int[n<<1];
		xc=new int[n<<1];
		for(int i = 1;i<n;i++) {
			int pd=ya[i-1]>>1,pb=ya[i-1]&1,nd=ya[i]>>1,nb=ya[i]&1;
			yb[i]=yb[i-1];
			if(nd!=pd&&(pb==1||nb==0)){
				if(nd==pd+1||pb==0||nb==1){
					yc[yb[i]+nb]=Max(yc[yb[i]+nb],nd-pd);
					yb[i]++;
				}
				else{
					yb[i]+=2;
					yc[yb[i]-1]=nd-pd-1;
				}
			}
			else if(nd!=pd){
				yc[yb[i]]=nd-pd+1;
			}
			else if(pb==0&&nb==1){
				yc[yb[i]]=1;
			}
			pd=xa[i-1]>>1;pb=xa[i-1]&1;nd=xa[i]>>1;nb=xa[i]&1;
			xb[i]=xb[i-1];
			if(nd!=pd&&(pb==1||nb==0)){
				if(nd==pd+1||pb==0||nb==1){
					xc[xb[i]+nb]=Max(xc[xb[i]+nb],nd-pd);
					xb[i]++;
				}
				else{
					xb[i]+=2;
					xc[xb[i]-1]=nd-pd-1;
				}
			}
			else if(nd!=pd){
				xc[xb[i]]=nd-pd+1;
			}
			else if(pb==0&&nb==1){
				xc[xb[i]]=1;
			}
		}

		my=yb[n-1]+1;
		mx=xb[n-1]+1;
	}
	public int Qy(int y){
		int lb=-1,ub=ya.Length,mid=0;
		while(lb+1!=ub){
			mid=(ub+lb)/2;
			if(ya[mid]>>1==y){return yb[mid];}
			if(ya[mid]>>1>y){ub=mid;}
			else{lb=mid;}
		}
		return yb[ub]-1;
	}
	public int Qx(int x){
		int lb=-1,ub=xa.Length,mid=0;
		while(lb+1!=ub){
			mid=(ub+lb)/2;
			if(xa[mid]>>1==x){return xb[mid];}
			if(xa[mid]>>1>x){ub=mid;}
			else{lb=mid;}
		}
		return xb[ub]-1;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 80244