#include <cstdio>
#include <vector>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n;
int main() {
	scanf("%d", &n);
	vector<int> ax(n), ay(n), bx(n), by(n), cx, cy;
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d%d", &ax[i], &ay[i], &bx[i], &by[i]);
		cx.push_back(ax[i]);
		cy.push_back(ay[i]);
		cx.push_back(bx[i]);
		cy.push_back(by[i]);
	}
	sort(cx.begin(), cx.end());
	cx.erase(unique(cx.begin(), cx.end()), cx.end());
	sort(cy.begin(), cy.end());
	cy.erase(unique(cy.begin(), cy.end()), cy.end());
	for (int i = 0; i < n; i++) {
		ax[i] = lower_bound(cx.begin(), cx.end(), ax[i]) - cx.begin();
		ay[i] = lower_bound(cy.begin(), cy.end(), ay[i]) - cy.begin();
		bx[i] = lower_bound(cx.begin(), cx.end(), bx[i]) - cx.begin();
		by[i] = lower_bound(cy.begin(), cy.end(), by[i]) - cy.begin();
	}
	vector<vector<int> > yi(cy.size()), yo(cy.size());
	for (int i = 0; i < n; i++) {
		yi[ay[i]].push_back(i);
		yo[by[i]].push_back(i);
	}
	vector<int> d(cx.size() - 1);
	long long ret = 0;
	for (int i = 0; i < cy.size(); i++) {
		if (i) {
			long long sum = 0;
			for (int j = 0; j < cx.size() - 1; j++) {
				if (d[j]) sum += cx[j + 1] - cx[j];
			}
			ret += sum * (cy[i] - cy[i - 1]);
		}
		for (int j : yi[i]) {
			for (int k = ax[j]; k < bx[j]; k++) d[k]++;
		}
		for (int j : yo[i]) {
			for (int k = ax[j]; k < bx[j]; k++) d[k]--;
		}
	}
	printf("%lld\n", ret);
	return 0;
}