#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
struct sTree {
  int pl, pr;
  int val, cnt, debt;
} tree[4000009];
int treeSize;
int NewNode(int LL, int RR) {
  int cur = ++treeSize;
  tree[cur].cnt = RR - LL + 1;
  return cur;
}
void CalcDebt(int LL, int RR, int cur);
void Add(int L, int R, int d, int LL, int RR, int cur) {
  if (L <= LL && R >= RR) {
    tree[cur].debt += d;
    tree[cur].val += d;
    return;
  }
  int M = LL + (RR - LL) / 2;
  if (!tree[cur].pl) tree[cur].pl = NewNode(LL, M);
  if (!tree[cur].pr) tree[cur].pr = NewNode(M + 1, RR);
  CalcDebt(LL, RR, cur);
  if (L <= M && LL <= R) {
    Add(L, R, d, LL, M, tree[cur].pl);
  }
  if (L <= RR && M + 1 <= R) {
    Add(L, R, d, M + 1, RR, tree[cur].pr);
  }
  if (tree[tree[cur].pl].val < tree[tree[cur].pr].val) {
    tree[cur].val = tree[tree[cur].pl].val;
    tree[cur].cnt = tree[tree[cur].pl].cnt;
  } else if (tree[tree[cur].pl].val > tree[tree[cur].pr].val) {
    tree[cur].val = tree[tree[cur].pr].val;
    tree[cur].cnt = tree[tree[cur].pr].cnt;
  } else {
    tree[cur].val = tree[tree[cur].pl].val;
    tree[cur].cnt = tree[tree[cur].pl].cnt + tree[tree[cur].pr].cnt;
  }
}
int Get(int cur) {
  if (tree[cur].val == 0) {
    return 2 * inf + 1 - tree[cur].cnt;
  }
  return 2 * inf + 1;
}
void CalcDebt(int LL, int RR, int cur) {
  int M = LL + (RR - LL) / 2;
  Add(LL, M, tree[cur].debt, LL, M, tree[cur].pl);
  Add(M + 1, RR, tree[cur].debt, M + 1, RR, tree[cur].pr);
  tree[cur].debt = 0;
}
int n;
struct event {
  char type;
  int p, L, R;
} e[200009];
bool operator<(event a, event b) {
  if (a.p != b.p) return a.p < b.p;
  return a.type < b.type;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1 += inf, y1 += inf, x2 += inf, y2 += inf;
    e[2 * i].type = '+';
    e[2 * i].p = min(x1, x2) - 1;
    e[2 * i].L = min(y1, y2);
    e[2 * i].R = max(y1, y2);
    e[2 * i + 1].type = '-';
    e[2 * i + 1].p = max(x1, x2);
    e[2 * i + 1].L = min(y1, y2);
    e[2 * i + 1].R = max(y1, y2);
  }
  sort(e, e + 2 * n);
  int root = NewNode(0, 2 * inf);
  long long ans = 0;
  int prev = -1;
  for (int i = 0; i < 2 * n; i++) {
    int j = i;
    while (j + 1 < 2 * n && e[j + 1].p == e[i].p) j++;
    ans += 1LL * Get(root) * (e[i].p - prev);
    for (int k = i; k <= j; k++) {
      if (e[k].type == '+') {
        Add(e[k].L, e[k].R, 1, 0, 2 * inf, root);
      } else {
        Add(e[k].L, e[k].R, -1, 0, 2 * inf, root);
      }
    }
    i = j;
    prev = e[i].p;
  }
  cout << ans;
}
