#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100000 + 50;
int ti[maxn << 3];
long long len[maxn << 3];
struct line {
  int x;
  int up, down;
  bool le;
  bool operator<(const line& p) const { return x < p.x; }
};
line li[maxn << 2];
long long use[maxn << 2];
int cnt;
int n, m;
void init() {
  sort(use, use + cnt);
  m = unique(use, use + cnt) - use - 1;
}
int gggg(int x) { return lower_bound(use + 1, use + 1 + m, x) - use; }
void pushup(int rt, int l, int r) {
  if (ti[rt])
    len[rt] = use[r] - use[l - 1];
  else if (l == r)
    len[rt] = 0;
  else
    len[rt] = len[rt << 1] + len[rt << 1 | 1];
}
void update(int rt, int l, int r, int ul, int ur, int val) {
  if (ul <= l && ur >= r) {
    ti[rt] += val;
    pushup(rt, l, r);
    return;
  }
  int mid = (l + r) >> 1;
  if (ul <= mid) update(rt << 1, l, mid, ul, ur, val);
  if (ur > mid) update(rt << 1 | 1, mid + 1, r, ul, ur, val);
  pushup(rt, l, r);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  int all = 0;
  for (int i = 0; i < n; i++) {
    long long x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 > x2) swap(x1, x2);
    x2++;
    if (y1 > y2) swap(y1, y2);
    use[cnt++] = y1 - 1;
    use[cnt++] = y2;
    li[all].x = x1;
    li[all].up = y2;
    li[all].down = y1;
    li[all++].le = 1;
    li[all] = li[all - 1];
    li[all].x = x2;
    li[all++].le = 0;
  }
  init();
  sort(li, li + all);
  update(1, 1, m, gggg(li[0].down), gggg(li[0].up), 1);
  long long ans = 0;
  long long pre = li[0].x;
  for (int i = 1; i < all; i++) {
    ans += len[1] * (li[i].x - pre);
    pre = li[i].x;
    if (li[i].le)
      update(1, 1, m, gggg(li[i].down), gggg(li[i].up), 1);
    else
      update(1, 1, m, gggg(li[i].down), gggg(li[i].up), -1);
  }
  cout << ans;
  return 0;
}
