#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct node {
  int l, r, cov;
  long long len;
  int mid() { return (l + r) >> 1; }
} t[N << 2];
int n, y[N], tot;
void pu(int u) {
  if (t[u].cov)
    t[u].len = y[t[u].r] - y[t[u].l];
  else
    t[u].len = t[u << 1].len + t[u << 1 | 1].len;
}
void build(int u, int l, int r) {
  t[u].l = l;
  t[u].r = r;
  t[u].cov = t[u].len = 0;
  if (r - l <= 1) return;
  int mid = t[u].mid();
  build(u << 1, l, mid);
  build(u << 1 | 1, mid, r);
}
void upd(int u, int l, int r, int ad) {
  if (t[u].l == l && t[u].r == r) {
    t[u].cov += ad;
    if (t[u].cov)
      t[u].len = y[t[u].r] - y[t[u].l];
    else {
      if (r - l <= 1)
        t[u].len = 0;
      else
        t[u].len = t[u << 1].len + t[u << 1 | 1].len;
    }
    return;
  }
  int mid = t[u].mid();
  if (r <= mid)
    upd(u << 1, l, r, ad);
  else if (l >= mid)
    upd(u << 1 | 1, l, r, ad);
  else {
    upd(u << 1, l, mid, ad);
    upd(u << 1 | 1, mid, r, ad);
  }
  pu(u);
}
struct _line {
  int x;
  int y_left, y_right;
  int val;
} l[N];
int totl;
bool cmp(_line a, _line b) { return a.x < b.x; }
int main() {
  scanf("%d", &n);
  tot = 1;
  totl = 0;
  for (int i = 0; i < n; i++) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      if (y1 > y2) swap(y1, y2);
      l[totl].x = x1;
      l[totl].val = -1;
      l[totl].y_left = y1;
      l[totl++].y_right = y2 + 1;
      l[totl].x = x1 + 1;
      l[totl].val = 1;
      l[totl].y_left = y1;
      l[totl++].y_right = y2 + 1;
      y[tot++] = y1;
      y[tot++] = y2 + 1;
    } else {
      if (x1 > x2) swap(x1, x2);
      l[totl].x = x1;
      l[totl].val = -1;
      l[totl].y_left = y1;
      l[totl++].y_right = y1 + 1;
      l[totl].x = x2 + 1;
      l[totl].val = 1;
      l[totl].y_left = y1;
      l[totl++].y_right = y1 + 1;
      y[tot++] = y1;
      y[tot++] = y1 + 1;
    }
  }
  sort(y + 1, y + tot);
  tot = unique(y + 1, y + tot) - y;
  sort(l, l + totl, cmp);
  build(1, 1, tot - 1);
  long long ans = 0;
  for (int i = totl - 1; i > 0; i--) {
    _line u = l[i];
    int _l = lower_bound(y + 1, y + tot, u.y_left) - y;
    int _r = lower_bound(y + 1, y + tot, u.y_right) - y;
    upd(1, _l, _r, u.val);
    ans += t[1].len * (u.x - l[i - 1].x);
  }
  cout << ans << endl;
  return 0;
}
