#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
struct Line {
  int x1, x2, h, flag;
  friend bool operator<(Line a, Line b) { return a.h < b.h; }
} edge[MAXN << 2];
long long cover[MAXN << 4], sum[MAXN << 4];
int w[MAXN << 2], tot = 0, lenx = 0;
void add(int x1, int x2, int h, int cover) {
  edge[tot] = {x1, x2, h, cover};
  tot++;
}
void unit() {
  int k = lenx;
  lenx = 1;
  for (int i = 1; i < k; i++) {
    if (w[i] != w[i - 1]) w[lenx++] = w[i];
  }
}
int id(int x) {
  int l = 0, r = lenx;
  while (l <= r) {
    int mid = l + r >> 1;
    if (w[mid] == x)
      return mid;
    else if (w[mid] < x)
      l = mid + 1;
    else
      r = mid - 1;
  }
  return -1;
}
void pushup(int l, int r, int rt) {
  if (cover[rt] > 0)
    sum[rt] = w[r] - w[l];
  else if (l == r - 1)
    sum[rt] = 0;
  else
    sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
}
void upd(int ql, int qr, int flag, int l, int r, int rt) {
  if (ql <= l && r <= qr) {
    cover[rt] += flag;
    pushup(l, r, rt);
    return;
  } else if (r - 1 == l)
    return;
  int mid = l + r >> 1;
  if (mid >= ql) upd(ql, qr, flag, l, mid, rt << 1);
  if (mid < qr) upd(ql, qr, flag, mid, r, rt << 1 | 1);
  pushup(l, r, rt);
}
int main() {
  int n, x1, x2, y1, y2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    if (x2 < x1 || y2 < y1) swap(x1, x2), swap(y1, y2);
    x1--, y1--;
    add(x1, x2, y1, 1);
    add(x1, x2, y2, -1);
    w[lenx++] = x1, w[lenx++] = x2;
  }
  sort(w, w + lenx);
  unit();
  sort(edge, edge + tot);
  long long ans = 0;
  for (int i = 0; i < tot - 1; i++) {
    int ql = id(edge[i].x1);
    int qr = id(edge[i].x2);
    upd(ql, qr, edge[i].flag, 0, lenx - 1, 1);
    ans += (edge[i + 1].h - edge[i].h) * sum[1];
  }
  cout << ans << endl;
  return 0;
}
