#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7;
const int SS = 4 * N;
struct Query {
  int l, r, val;
};
int add[SS], seg[SS];
vector<Query> q[N];
vector<int> cy, cx;
int xl[N], yl[N], xr[N], yr[N];
void comp(vector<int> &v) {
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
}
void set_comp(int &val, vector<int> &v) {
  val = lower_bound(v.begin(), v.end(), val) - v.begin();
}
void build(int s = 0, int e = cy.size() - 1, int v = 1) {
  if (e - s == 1) {
    seg[v] = cy[e] - cy[s];
    return;
  }
  int mid = (s + e) / 2;
  build(s, mid, 2 * v);
  build(mid, e, 2 * v + 1);
  seg[v] = seg[2 * v] + seg[2 * v + 1];
}
void upd(int l, int r, int val, int s = 0, int e = cy.size() - 1, int v = 1) {
  if (l >= e || r <= s) return;
  if (l <= s && e <= r) {
    add[v] += val;
    return;
  }
  int mid = (s + e) / 2;
  upd(l, r, val, s, mid, 2 * v);
  upd(l, r, val, mid, e, 2 * v + 1);
  seg[v] =
      seg[2 * v] * (add[2 * v] == 0) + seg[2 * v + 1] * (add[2 * v + 1] == 0);
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> xl[i] >> yl[i] >> xr[i] >> yr[i];
    if (xl[i] > xr[i]) swap(xl[i], xr[i]);
    if (yl[i] > yr[i]) swap(yl[i], yr[i]);
    xr[i]++;
    yr[i]++;
    cx.push_back(xl[i]);
    cx.push_back(xr[i]);
    cy.push_back(yl[i]);
    cy.push_back(yr[i]);
  }
  comp(cx);
  comp(cy);
  build();
  for (int i = 0; i < n; i++) {
    set_comp(xl[i], cx);
    set_comp(xr[i], cx);
    set_comp(yl[i], cy);
    set_comp(yr[i], cy);
    q[xl[i]].push_back({yl[i], yr[i], 1});
    q[xr[i]].push_back({yl[i], yr[i], -1});
  }
  long long ans = 0;
  for (int i = 0; i < cx.size(); i++) {
    for (int j = 0; j < q[i].size(); j++)
      upd(q[i][j].l, q[i][j].r, q[i][j].val);
    if (i + 1 < cx.size())
      ans += 1LL * (cy.back() - cy[0] - (add[1] == 0) * seg[1]) *
             (cx[i + 1] - cx[i]);
  }
  cout << ans << "\n";
  return 0;
}
