#include <bits/stdc++.h>
template <typename _T>
inline bool read(_T& x) {
  x = 0;
  _T y = 1;
  char c = getchar();
  while ((c < '0' || '9' < c) && c != EOF) {
    if (c == '-') y = -1;
    c = getchar();
  }
  if (c == EOF) return false;
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
  x *= y;
  return true;
}
int N, ts, top;
long long a[600007 << 1], tag[600007 << 2], sum[600007 << 2];
long long res;
struct seg {
  long long l, r, h, v;
  bool operator<(const seg& rhs) const { return h < rhs.h; }
} s[600007];
inline void update(int x, int l, int r) {
  if (tag[x])
    sum[x] = a[r + 1] - a[l];
  else
    sum[x] = sum[x << 1] + sum[x << 1 | 1];
}
void modify(int x, int l, int r, int ql, int qr, long long val) {
  if (ql <= l && r <= qr) return tag[x] += val, update(x, l, r);
  int mid = l + r >> 1;
  if (ql <= mid) modify(x << 1, l, mid, ql, qr, val);
  if (mid < qr) modify(x << 1 | 1, mid + 1, r, ql, qr, val);
  update(x, l, r);
}
int main() {
  read(N);
  int a1, a2, b1, b2;
  for (int i = 1; i <= N; ++i) {
    read(a1), read(b1), read(a2), read(b2);
    if (a1 > a2) std::swap(a1, a2);
    if (b1 > b2) std::swap(b1, b2);
    a2++, b2++;
    s[++ts] = {b1, b2, a1, 1};
    s[++ts] = {b1, b2, a2, -1};
    a[++top] = b1, a[++top] = b2;
  }
  std::sort(a + 1, a + top + 1);
  top = std::unique(a + 1, a + top + 1) - a - 1;
  std::sort(s + 1, s + ts + 1);
  int l, r;
  for (int i = 1; i <= ts - 1; ++i) {
    l = std::lower_bound(a + 1, a + top + 1, s[i].l) - a;
    r = std::lower_bound(a + 1, a + top + 1, s[i].r) - a - 1;
    modify(1, 1, top, l, r, s[i].v);
    res += sum[1] * (s[i + 1].h - s[i].h);
  }
  printf("%lld\n", res);
  return 0;
}
