#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

struct data {
	int x, l, r, type;
};

struct seg {
	int cnt;
	ll len;
};

const int N = 2e5 + 5;

int n, m, k;
ll ans;
ll values[N];
data a[N];
seg t[4*N];

bool cmp(data u, data v) {
	return (u.x < v.x || (u.x == v.x && u.type < v.type));
}

void update(int id, int l, int r, int u, int v, int type) {
	
	if (r < u || v < l) return ;
	if (u <= l && r <= v) {
		t[id].cnt += type;
		if (type == 1) t[id].len = values[r] - values[l - 1];
		else if (t[id].cnt == 0) if (l < r) t[id].len = t[id * 2].len + t[id * 2 + 1].len;
		else t[id].len = 0;
		return ;
	}
	int mid = (l + r) / 2;
	update(id * 2, l, mid, u, v, type);
	update(id * 2 + 1, mid + 1, r, u, v, type);
	if (t[id].cnt == 0 && l < r) t[id].len = t[id * 2].len + t[id * 2 + 1].len;
}

int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);

	cin >> n;
	vector<int> cost;
	for (int i = 1; i <= n; i++) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		a[++m] = {x1, y1, y2, 1};
		a[++m] = {x2, y1, y2, -1};
		cost.push_back(y1);
		cost.push_back(y2);
	}
	sort(cost.begin(), cost.end());
	cost.resize(unique(cost.begin(), cost.end()) - cost.begin());
	sort(a+1,a+m+1,cmp);
	for (int i = 1; i <= m; i++) {
		int l = a[i].l;
		int m = lower_bound(cost.begin(), cost.end(), a[i].l) - cost.begin() + 1;
		a[i].l = m;
		values[m] = l;
		int r = a[i].r;
		int m_ = lower_bound(cost.begin(), cost.end(), a[i].r) - cost.begin() + 1;
		a[i].r = m_;
		values[m_] = r;
		k = max(k, a[i].r);
	}
	for (int i = 1; i <= m; i++) {
		ans += (ll)t[1].len * (ll)(a[i].x - a[i-1].x);
//		cout << ans << " - > ";
//		cout << t[1].len << " - > ";
		update(1, 1, k, a[i].l + 1, a[i].r, a[i].type);
	}
	cout << ans;
	return 0;
}