include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
define x first
define y second
using namespace std;
typedef long long LL;
typedef pair[HTML_REMOVED] PII;
const int N = 1010;
int n;
PII l[N], r[N];
LL range_area(int a, int b)
{
vector[HTML_REMOVED] vec;
LL res = 0;
for (int i = 0; i < n; i)
if (l[i].x <= a && r[i].x >= b)
vec.push_back({l[i].y, r[i].y});
if (vec.empty()) return 0;
sort(vec.begin(), vec.end());
int st = vec[0].x, ed = vec[0].y;
for (int i = 1; i < vec.size(); i)
if (vec[i].x <= ed) ed = max(ed, vec[i].y);
else
{
res += ed - st;
st = vec[i].x, ed = vec[i].y;
}
res += ed - st;
return res * (b - a);
}
int main()
{
vector[HTML_REMOVED] xs;
cin >> n;
for (int i = 0; i < n; i)
{
cin >> l[i].x >> l[i].y >> r[i].x >> r[i].y;
xs.push_back(l[i].x), xs.push_back(r[i].x);
}
sort(xs.begin(), xs.end());
LL res = 0;
for (int i = 0; i + 1 < xs.size(); i)
if (xs[i] != xs[i + 1])
res += range_area(xs[i], xs[i + 1]);
cout << res << endl;
}