#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};

ll n;

ll compress(ll *x1, ll *x2, ll w){
    vll xs;
    xs.pb(0);
    xs.pb(w-1);
    rep(i,n){
        rep2(d,0,2){
            ll a=x1[i]+d-1, b=x2[i]+d;
            if(d!=0)if(0<=a&&a<w) xs.eb(a);
            if(0<=b&&b<w) xs.eb(b);
        }
    }
    // sort(all(xs));
    ERASE(xs);
    rep(i,n+2){
        x1[i]=find(all(xs),x1[i])-xs.begin();
        x2[i]=find(all(xs),x2[i])-xs.begin();
    }
    return xs.size();
}


ll field[4010][4010];

void solve(){
    ll x1[2010],y1[2010],x2[2010],y2[2010];
    cin>>n;
    vll x,y,z;
    rep(i,n){
        cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
        x.pb(x1[i]);
        x.pb(x2[i]);
        y.pb(y1[i]);
        y.pb(y2[i]);
    }
    ERASE(x);
    ERASE(y);

    ll h=x.size(),w=y.size();
    ll ans=0;
    rep(i,h+2)rep(j,w+2) field[i][j]=0;

    rep(i,n){
        ll a=find(all(x),x1[i])-x.begin();
        ll b=find(all(x),x2[i])-x.begin();
        ll c=find(all(y),y1[i])-y.begin();
        ll d=find(all(y),y2[i])-y.begin();
        // cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
        field[a][c]++;
        field[a][d]--;
        field[b][c]--;
        field[b][d]++;
    }
    // cerr<<endl;

    // rep(i,h+2){
    //     rep(j,w+2){
    //         cout<<field[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    

    rep(i,h) rep(j,w-1) field[i][j+1]+=field[i][j];
    rep(j,w) rep(i,h-1) field[i+1][j]+=field[i][j];

    rep(i,h-1){
        rep(j,w-1){
            if(field[i][j]>0){
                ans+=(x[i+1]-x[i])*(y[j+1]-y[j]);
            }
        }
    }
    
    // rep(i,h+2){
    //     rep(j,w+2){
    //         cout<<field[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    cout<<ans<<endl;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}



Measured memory_bytes: 128744