#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int cnt[maxn << 2];
long long sum[maxn << 2];
long long first[maxn];
struct Seg {
  long long l, r, h;
  int s;
  Seg() {}
  Seg(long long a, long long b, long long c, int d) : l(a), r(b), h(c), s(d) {}
  bool operator<(const Seg &cmp) const { return h < cmp.h; }
} ss[maxn];
void pushup(int rt, int l, int r) {
  if (cnt[rt])
    sum[rt] = first[r + 1] - first[l];
  else if (l == r)
    sum[rt] = 0;
  else
    sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
}
void update(int L, int R, int c, int l, int r, int rt) {
  if (L <= l && r <= R) {
    cnt[rt] += c;
    pushup(rt, l, r);
    return;
  }
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, c, l, m, rt << 1);
  if (m < R) update(L, R, c, m + 1, r, rt << 1 | 1);
  pushup(rt, l, r);
}
int Bin(long long key, int n, long long x[]) {
  int l = 0, r = n - 1;
  while (l <= r) {
    int m = (l + r) >> 1;
    if (first[m] == key) return m;
    if (first[m] < key)
      l = m + 1;
    else
      r = m - 1;
  }
  return -1;
}
int main() {
  int n, m = 0;
  scanf("%d", &n);
  while (n--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (a > c) swap(a, c);
    if (b > d) swap(b, d);
    first[m] = a - 1;
    ss[m++] = Seg(a - 1, c, b - 1, 1);
    first[m] = c;
    ss[m++] = Seg(a - 1, c, d, -1);
  }
  sort(first, first + m);
  sort(ss, ss + m);
  int k = 1;
  for (int i = 1; i < m; i++)
    if (first[i] != first[i - 1]) first[k++] = first[i];
  ;
  memset(cnt, 0, sizeof(cnt));
  ;
  ;
  memset(sum, 0, sizeof(sum));
  ;
  long long ret = 0;
  for (int i = 0; i < m - 1; i++) {
    int l = Bin(ss[i].l, k, first);
    int r = Bin(ss[i].r, k, first) - 1;
    if (l <= r) update(l, r, ss[i].s, 0, k - 1, 1);
    ret += sum[1] * (ss[i + 1].h - ss[i].h);
  }
  printf("%I64d\n", ret);
}
