#include <bits/stdc++.h>
using namespace std;
int n, np, nh, nv, x[200005], l, xx[200005], ll, nh2, nv2, sum[800005];
long long ans;
map<int, int> a;
struct point {
  int x, y;
  bool operator<(const point &z) const { return y < z.y; }
} s[100005], e[100005];
struct horizontal {
  int y, l, r;
  bool operator<(const horizontal &x) const {
    if (y == x.y)
      return l < x.l;
    else
      return y < x.y;
  }
} h[100005], h2[100005];
struct vertical {
  int x, t, b;
  bool operator<(const vertical &y) const {
    if (x == y.x)
      return b < y.b;
    else
      return x < y.x;
  }
} v[100005], v2[100005];
int abs(int x) { return x > 0 ? x : 0; }
int min(int x, int y) { return x < y ? x : y; }
int max(int x, int y) { return x > y ? x : y; }
void update(int l, int r, int p, int v, int i) {
  if (l == r) {
    sum[i] += v;
    return;
  }
  int mid = (l + r) / 2;
  if (l <= p && p <= mid)
    update(l, mid, p, v, i * 2);
  else
    update(mid + 1, r, p, v, i * 2 + 1);
  sum[i] = sum[i * 2] + sum[i * 2 + 1];
}
int query(int l, int r, int ql, int qr, int i) {
  if (ql <= l && r <= qr) return sum[i];
  int x = 0, mid = (l + r) / 2;
  if (l <= ql && ql <= mid || l <= qr && qr <= mid || ql <= l && mid <= qr)
    x += query(l, mid, ql, qr, i * 2);
  if (mid + 1 <= ql && ql <= r || mid + 1 <= qr && qr <= r ||
      ql <= mid + 1 && r <= qr)
    x += query(mid + 1, r, ql, qr, i * 2 + 1);
  return x;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      v[nv].x = x1;
      v[nv].t = max(y1, y2);
      v[nv++].b = min(y1, y2);
    } else {
      h[nh].l = min(x1, x2);
      h[nh].r = max(x1, x2);
      h[nh++].y = y1;
    }
    x[l++] = x1;
    x[l++] = x2;
  }
  sort(x, x + l);
  sort(v, v + nv);
  sort(h, h + nh);
  for (int i = 0; i < l; i++)
    if (i == 0 || x[i] != x[i - 1]) xx[ll++] = x[i];
  for (int i = 0; i < ll; i++) a[xx[i]] = i;
  for (int i = 0; i < nh; i++) {
    if (i + 1 != nh && h[i].y == h[i + 1].y && h[i].r >= h[i + 1].l) {
      h[i + 1].l = h[i].l;
      if (h[i].r > h[i + 1].r) h[i + 1].r = h[i].r;
    } else
      h2[nh2++] = h[i];
  }
  for (int i = 0; i < nv; i++) {
    if (i + 1 != nv && v[i].x == v[i + 1].x && v[i].t >= v[i + 1].b) {
      v[i + 1].b = v[i].b;
      if (v[i].t > v[i + 1].t) v[i + 1].t = v[i].t;
    } else
      v2[nv2++] = v[i];
  }
  for (int i = 0; i < nv2; i++) {
    s[np].x = v2[i].x;
    s[np].y = v2[i].b;
    e[np].x = v2[i].x;
    e[np++].y = v2[i].t;
    ans += v2[i].t - v2[i].b + 1;
  }
  sort(s, s + np);
  sort(e, e + np);
  for (int i = 0, j = 0, k = 0; i < nh2; i++) {
    while (k < np && e[k].y < h2[i].y) update(0, ll - 1, a[e[k++].x], -1, 1);
    while (j < np && s[j].y <= h2[i].y) update(0, ll - 1, a[s[j++].x], 1, 1);
    ans += h2[i].r - h2[i].l + 1 - query(0, ll - 1, a[h2[i].l], a[h2[i].r], 1);
  }
  printf("%I64d\n", ans);
  scanf("\n");
  return 0;
}
