#define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define rep0(N) for (int COUNTER = 0; COUNTER < (int)(N); COUNTER++)
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define rep1(i, N) for (int i = 0; i < (int)(N); i++)
#define rep2(i, START, GOAL) for (int i = (int)(START); i < (int)(GOAL); i++)
#define rep3(i, START, GOAL) for (int i = (int)(START); i > (int)(GOAL); i--)
#define all(CONTAINER) CONTAINER.begin(), CONTAINER.end()
#define rall(CONTAINER) CONTAINER.rbegin(), CONTAINER.rend()
#define from1(CONTAINER) CONTAINER.begin() + 1, CONTAINER.end()
#define rfrom1(CONTAINER) CONTAINER.rbegin(), CONTAINER.rend() - 1
#define pout(X) cout << X << " "
#define print(X) cout << X << "\n"
#define output(X) cout << X << "\n"
#define dbe(X) cerr << X << " "
#define dberr(X) cerr << X << " "
#define dbel(X) cerr << X << "\n"
#define dberrl(X) cerr << X << "\n"
#define db(X) cerr << #X << ":" << (X) << " "
#define dbl(X) cerr << #X << ":" << (X) << "\n"
#define db2(X, Y) cerr << #X << ":" << (X) << ", " << #Y << ":" << (Y) << " "
#define db2l(X, Y) cerr << #X << ":" << (X) << ", " << #Y << ":" << (Y) << "\n"
#define dbl2(X, Y) cerr << #X << ":" << (X) << "\n" << #Y << ":" << (Y) << "\n"
#define db3(X, Y, Z) cerr << #X << ":" << (X) << ", " << #Y << ":" << (Y) << " " << #Z << ":" << (Z) << " "
#define db3l(X, Y, Z) cerr << #X << ":" << (X) << ", " << #Y << ":" << (Y) << ", " << #Z << ":" << (Z) << "\n"
#define dbl3(X, Y, Z) cerr << #X << ":" << (X) << "\n" << #Y << ":" << (Y) << "\n" << #Z << ":" << (Z) << "\n"
#define dbp(PAIR) cerr << #PAIR << ":(" << PAIR.first << ", " << PAIR.second << ") "
#define dbpl(PAIR) cerr << #PAIR << ":(" << PAIR.first << ", " << PAIR.second << ")\n"
#define dbt3(TUPLE3) cerr << #TUPLE3 << ":(" << get<0>(TUPLE3) << ", " << get<1>(TUPLE3) << ", " << get<2>(TUPLE3) << ") "
#define dbt3l(TUPLE3) cerr << #TUPLE3 << ":(" << get<0>(TUPLE3) << ", " << get<1>(TUPLE3) << ", " << get<2>(TUPLE3) << ")\n"
#define dbt4(TUPLE4) cerr << #TUPLE4 << ":(" << get<0>(TUPLE4) << ", " << get<1>(TUPLE4) << ", " << get<2>(TUPLE4) << ", " << get<3>(TUPLE4) << ") "
#define dbt4l(TUPLE4) cerr << #TUPLE4 << ":(" << get<0>(TUPLE4) << ", " << get<1>(TUPLE4) << ", " << get<2>(TUPLE4) << ", " << get<3>(TUPLE4) << ")\n"
#define dbv(VEC) cerr << #VEC << ":{ "; for (auto ELEM : VEC) cerr << ELEM << ", "; cerr << "}\n"
#define dbvp(VP) cerr << #VP << ":{ "; for (auto PAIR : VP) cerr << "(" << PAIR.first << ", " << PAIR.second << "), "; cerr << "}\n"
#define dbvv(VV) cerr << #VV << ":{\n"; for (auto VEC : VV) { cerr << "{ "; for (auto ELEM : VEC) cerr << ELEM << ", "; cerr << "},\n"; } cerr << "}\n"
#define dbvvp(VVP) cerr << #VVP <<":{\n"; for (auto VP : VVP) { cerr << "{ "; for (auto PAIR : VP) { cerr << "(" << PAIR.first << ", " << PAIR.second << "), "; } cerr << "},\n"; } cerr << "}\n";
#define dbs(SET) cerr << #SET << "{ "; for (auto ELEM : SET) cerr << ELEM << ", "; cerr << "}\n";
#define dbsp(SP) cerr << #SP << "{ "; for (auto PAIR : SP) cerr << "(" << PAIR.first << ", " << PAIR.second << "), "; "}\n";
#define dbm(MAP) cerr << #MAP << ":{ "; for (auto PAIR : MAP) cerr << "(" << PAIR.first << ", " << PAIR.second << "), "; cerr << "}\n"
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>; using vl = vector<ll>; using vd = vector<double>; using vs = vector<string>; using vb = vector<bool>;
using vvi = vector<vi>; using vvl = vector<vl>; using vvd = vector<vd>; using vvb = vector<vb>;
using pii = pair<int, int>; using pil = pair<int, ll> ; using pli = pair<ll, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>;
using vpii = vector<pii>; using vpll = vector<pll>; using vpdd = vector<pdd>;
using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>; using td3 = tuple<double, double, double>;
using ti4 = tuple<int, int, int, int>; using tl4 = tuple<ll, ll, ll, ll>; using td4 = tuple<double, double, double, double>;
using mii = map<int, int>; using mil = map<int, ll>; using mli = map<ll, int>; using mll = map<ll, ll>;
using si = set<int>; using sl = set<ll>; using sl = set<ll>; using ss = set<string>; using spii = set<pii>; using spll = set<pll>; using spdd = set<pdd>;
// db

int N;
vvi x, y;
si sx, sy;
vi vx, vy;
vi dx, dy;
mii xtoi, ytoj;

int main() {
	cin >> N;
	x.assign(2, {}); y.assign(2, {});
	rep(i, 2) {	x[i].assign(N, 0); y[i].assign(N, 0); }
	rep(i, N) {
		cin >> x[0][i] >> y[0][i] >> x[1][i] >> y[1][i];
		sx.insert(x[0][i]);		
		sy.insert(y[0][i]);
		sx.insert(x[1][i]);
		sy.insert(y[1][i]);	
	}
	
	int cnt = 0;
	for (auto it = sx.begin(); it != sx.end(); it++) {
		vx.push_back(*it);
		xtoi[*it] = cnt;
		cnt++;
	}
	rep(ix, xtoi.size() - 1) dx.push_back(vx[ix + 1] - vx[ix]); // 隣接点間の距離	
	
	cnt = 0;
	for (auto jt = sy.begin(); jt != sy.end(); jt++) {
		vy.push_back(*jt);
		ytoj[*jt] = cnt;
		cnt++;
	}
	rep(jy, ytoj.size() - 1) dy.push_back(vy[jy + 1] - vy[jy]);
	/*
	rep(i, N) { dbp(pii(x[0][i], y[0][i])); dbpl(pii(x[1][i], y[1][i])); } // (x1,y1), (x2,y2)
	dbvv(x); dbvv(y);
	dbs(sx); dbs(sy); // set{xi}, set{yj}
	dbv(vx); dbv(vx);	// vector{xi}, vector{yj}
	dbv(dx); dbv(dy); // vector{di}, vector{yj}
	dbm(xtoi); dbm(ytoj); // map{(xi, i)}, map{(yj, j)}
	*/
	vvi imos(sx.size(), vi(sy.size()));
	rep(i, N) {
		int ix1 = xtoi[x[0][i]], jy1 = ytoj[y[0][i]];
		int ix2 = xtoi[x[1][i]], jy2 = ytoj[y[1][i]];
		imos[ix1][jy1]++; // jy1は端点の座標なのでjy1+1とはしない
		imos[ix1][jy2]--;
		imos[ix2][jy1]--;
		imos[ix2][jy2]++;
	}
	// 2D-imos
	// dbvv(imos);
	rep(ix, sx.size()) rep(jy, sy.size() - 1) imos[ix][jy + 1] += imos[ix][jy];
	// dbvv(imos);
	rep(jy, sy.size()) rep(ix, sx.size() - 1) imos[ix + 1][jy] += imos[ix][jy];
	// dbvv(imos);
	ll ans = 0;
	rep(ix, sx.size() - 1) rep(jy, sy.size() - 1) {
		if (imos[ix][jy]) {
			ans += (ll)dx[ix] * dy[jy];
		}
	}
	print(ans);	
}


Measured memory_bytes: 66460