#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

template <typename T>
vector<T> compress(vector<T> &C1, vector<T> &C2) {
    vector<T> vals;
    long long K = (long long)C1.size();
    for (long long i = 0; i < K; i++) {
        for (T d = 0; d < 1; d++) {  // その位置と、一つ隣を確保(隣を確保しないと空白が埋まってしまうことがある)
            T tc1 = C1[i] + d;
            T tc2 = C2[i] + d;
            vals.push_back(tc1);
            vals.push_back(tc2);
        }
    }
    // ソート
    sort(vals.begin(), vals.end());
    // 隣り合う重複を削除(unique), 末端のゴミを削除(erase)
    vals.erase(unique(vals.begin(), vals.end()), vals.end());
    for (long long i = 0; i < K; i++) {
        C1[i] = lower_bound(vals.begin(), vals.end(), C1[i]) - vals.begin();
        C2[i] = lower_bound(vals.begin(), vals.end(), C2[i]) - vals.begin();
    }
    return vals;
}

long long a[4000][4000] = {0};

int main() {
  long long N;
  cin >> N;
  vector<long long> x1, x2;
  vector<long long> y1, y2;
  rep(i, N) {
    long long p, q, r, s;
    cin >> p >> q >> r >> s;
    x1.push_back(p);
    y1.push_back(q);
    x2.push_back(r);
    y2.push_back(s);
  }
  vector<long long> x;
  vector<long long> y;
  x = compress(x1, x2);
  y = compress(y1, y2);

  // rep(i, N) {
  //   for(long long p = x1[i]; p < x2[i]; p++) {
  //     for(long long q = y1[i]; q < y2[i]; q++) {
  //       a[p][q] += 1;
  //     }
  //   }
  // }
  rep(i, N) {
    a[x1[i]][y1[i]] += 1;
    a[x1[i]][y2[i]] += -1;
    a[x2[i]][y1[i]] += -1;
    a[x2[i]][y2[i]] += 1;  
  }
  long long ans = 0;
  rep(i, x.size()) {
    rep(j, y.size()-1) {
      a[i][j+1] += a[i][j];
    }
  }
  rep(i, x.size()-1) {
    rep(j, y.size()) {
      a[i+1][j] += a[i][j];
    }
  }
  rep(i, x.size()-1) {
    rep(j, y.size()-1) {
      if(a[i][j] > 0) {
        ans += (x[i+1]-x[i]) * (y[j+1]-y[j]);
      }
      // cout << a[i][j] << " ";
    }
    // cout << endl;
  }
  
  cout << ans << endl;
  // rep(i, x1.size()) {
  //   cout << x1[i] << " "; 
  // }
  // cout << endl;
  // rep(i, y1.size()) {
  //   cout << y1[i] << " "; 
  // }
  // cout << endl;
  // rep(i, x2.size()) {
  //   cout << x2[i] << " "; 
  // }
  // cout << endl;
  // rep(i, y2.size()) {
  //   cout << y2[i] << " "; 
  // }
  // cout << endl;
  return 0;
}
