program STARWAR; {$APPTYPE CONSOLE} const inpf='Corusant.DAT'; outf='Corusant.SOL'; type list = array[1..20000] of integer; var f:text; i,n,n2,kilkx,kilky,zx,zy,zx1,zy1,m,b1,b2:integer; x,y,x1,y1,cx,cy:list; aa:array [1..20000,1..20000] of byte; area:Cardinal; procedure quicksort(var a: list; Lo,Hi: integer); procedure sort(l,r: integer); var i,j,x,y: integer; begin i:=l; j:=r; x:=a[(l+r) DIV 2]; repeat while a[i]j; if la[jj] then begin r:=a[ii]; a[ii]:=a[jj]; a[jj]:=r; end; end; function binfind(d:list; lo,hi,s:integer):integer; var v,l,h:integer; begin l:=lo; h:=hi; while true do begin if l+h mod 2=0 then v:=(l+h-1) div 2 else v:=(l+h) div 2; if (sd[v]) then l:=v+1 else begin Result:=v; exit; end; if l>h then begin Result:=-1; Exit; end; end; end; begin Assign (f,inpf); reset (f); readln (f,n); n2:=2*n; for i:=1 to n2 do if odd(i) then begin read(f,x[i],y[i]); cx[i]:=x[i]; cy[i]:=y[i]; end else begin readln (f,x[i],y[i]); cx[i]:=x[i]; cy[i]:=y[i]; end; close (f); if n2>100 then begin quicksort (cx,1,n2); quicksort (cy,1,n2); end else begin bulbaska(cx,1,n2); bulbaska(cy,1,n2); end; kilkx:=0; kilky:=0; for i:=1 to n2 do begin if i<>1 then begin if cx[i]<>cx[i-1] then begin inc(kilkx); x1[kilkx]:=cx[i]; end; if cy[i]<>cy[i-1] then begin inc(kilky); y1[kilky]:=cy[i]; end; end else begin kilkx:=1; kilky:=1; x1[1]:=cx[1]; y1[1]:=cy[1]; end; end; i:=1; while i<=n2 do begin zx:=binfind(x1,1,kilkx,x[i]); m:=zx+1; while x1[m]<>x[i+1] do inc(m); zx1:=m; zy:=binfind(y1,1,kilky,y[i]); m:=zy+1; while y1[m]<>y[i+1] do inc(m); zy1:=m; for b1:=zx to zx1-1 do for b2:=zy to zy1-1 do if aa[b1,b2]=0 then begin aa[b1,b2]:=1; inc(area,(x1[b1+1]-x1[b1])*(y1[b2+1]-y1[b2])) end; inc(i,2); end; assign (f,outf); rewrite (f); writeln (f,area); close (f); end.