P1884
#include <bits/stdc++.h>
using namespace std;
struct square{
int x1,x2,y1,y2;
}q[1005];
int tx[2005],ty[2005],x[2005],y[2005],xt1,yt1,xt2,yt2,n,xs,xe,ys,ye;
long long S;
void input(){
scanf("%d",&n);
for (int i = 0;i < n;i++){
scanf("%d %d %d %d",&q[i].x1,&q[i].y1,&q[i].x2,&q[i].y2);
tx[xt1++] = q[i].x1;
tx[xt1++] = q[i].x2;
ty[yt1++] = q[i].y1;
ty[yt1++] = q[i].y2;
}
}
void every(){
sort(tx,tx + xt1);
sort(ty,ty + yt1);
x[0] = tx[0],y[0] = ty[0];
for (int i = 1;i < xt1;i++){
if (tx[i] == tx[i - 1]) continue;
x[++xt2] = tx[i];
}
for (int i = 1;i < yt1;i++){
if (ty[i] == ty[i - 1]) continue;
y[++yt2] = ty[i];
}
}
bool have(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){
return (x3 >= x1 && x4 <= x2 && y3 <= y1 && y4 >= y2) ? true : false;
}
void f(){
every();
for (int i = 0;i <= xt2 - 1;i++){
xs = x[i];
xe = x[i + 1];
for (int j = 0;j <= yt2 - 1;j++){
ys = y[j + 1];
ye = y[j];
long long s = (xe - xs) * (ys - ye);
for (int k = 0;k < n;k++){
if (have(q[k].x1,q[k].y1,q[k].x2,q[k].y2,xs,ys,xe,ye)){
S += s;
break;
}
}
}
}
}
void output(){
printf("%lld",S);
}
int main(){
input();
f();
output();
return 0;
}