#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>

using namespace std;
long long x_s[2000];
long long x_e[2000];
long long y_s[2000];
long long y_e[2000];
int grid[4000][4000];
map <long long, int> x_to_ind;
map <long long, int> y_to_ind;
vector <long long> xs;
vector <long long> ys;
int main(void){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> x_s[i] >> y_s[i] >> x_e[i] >> y_e[i];
    }

    for(int i = 0; i < N; i++){
        xs.push_back(x_s[i]);
        xs.push_back(x_e[i]);
        ys.push_back(y_s[i]);
        ys.push_back(y_e[i]);
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    sort(ys.begin(), ys.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());

    for(int i = 0; i < N; i++){
        for(int j = 0; j < xs.size(); j++){
            if(xs[j] == x_s[i]){
                x_to_ind[x_s[i]] = j;
            }
            if(xs[j] == x_e[i]){
                x_to_ind[x_e[i]] = j;
            }
        }

        for(int j = 0; j < ys.size(); j++){
            if(ys[j] == y_s[i]){
                y_to_ind[y_s[i]] = j;
            }
            if(ys[j] == y_e[i]){
                y_to_ind[y_e[i]] = j;
            }
        }
    }

    for(int i = 0; i < N; i++){
        int x1_ind = x_to_ind[x_s[i]];
        int x2_ind = x_to_ind[x_e[i]];
        int y1_ind = y_to_ind[y_s[i]];
        int y2_ind = y_to_ind[y_e[i]];
        grid[x1_ind][y1_ind] ++;
        grid[x1_ind][y2_ind] --;
        grid[x2_ind][y1_ind] --;
        grid[x2_ind][y2_ind] ++;
    }    

    for(int i = 0; i < xs.size() - 1; i++){
        for(int j = 1; j < ys.size() - 1; j++){
            grid[i][j] += grid[i][j - 1];
        }
    }
    for(int j = 0; j < ys.size() - 1; j++){
        for(int i = 1; i < xs.size() - 1; i++){
            grid[i][j] += grid[i - 1][j];
        }
    }

    long long ans = 0;
    for(int i = 0; i < xs.size() - 1; i++){
        for(int j = 0; j < ys.size() - 1; j++){
            if(grid[i][j] > 0){
                ans += (xs[i + 1] - xs[i]) * (ys[j + 1] - ys[j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

