#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
struct node {
  int y, l, r, w;
  node() {}
  node(int _y, int _l, int _r, int _w) : y(_y), l(_l), r(_r), w(_w) {}
} line[N << 1];
map<long long, int> M;
long long x[N << 1];
bool cmp(node a, node b) { return a.y < b.y; }
struct Node {
  int l, r, w;
  long long len;
} tree[N << 2];
void build(int l, int r, int pos) {
  tree[pos].l = l;
  tree[pos].r = r;
  tree[pos].w = 0;
  tree[pos].len = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(l, mid, pos << 1);
  build(mid + 1, r, pos << 1 | 1);
}
void pushup(int pos) {
  if (tree[pos].w > 0)
    tree[pos].len = x[tree[pos].r + 1] - x[tree[pos].l];
  else if (tree[pos].l == tree[pos].r)
    tree[pos].len = 0;
  else
    tree[pos].len = tree[pos << 1].len + tree[pos << 1 | 1].len;
}
void update(int l, int r, int pos, int v) {
  if (l <= tree[pos].l && tree[pos].r <= r) {
    tree[pos].w += v;
    pushup(pos);
    return;
  }
  int mid = (tree[pos].l + tree[pos].r) >> 1;
  if (l <= mid) update(l, r, pos << 1, v);
  if (r > mid) update(l, r, pos << 1 | 1, v);
  pushup(pos);
}
int main() {
  int n, x1, x2, y1, y2;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 > x2) swap(x1, x2);
    if (y1 > y2) swap(y1, y2);
    x2++, y2++;
    line[2 * i] = node(y1, x1, x2, 1);
    line[2 * i + 1] = node(y2, x1, x2, -1);
    x[2 * i] = (long long)x1;
    x[2 * i + 1] = (long long)x2;
  }
  sort(line, line + 2 * n, cmp);
  sort(x, x + 2 * n);
  int tot = 1;
  for (int i = 1; i < 2 * n; i++)
    if (x[i] != x[i - 1]) x[tot++] = x[i];
  M.clear();
  for (int i = 0; i < tot; i++) M[x[i]] = i;
  build(0, tot - 2, 1);
  long long ans = 0;
  long long pre;
  for (int i = 0; i < 2 * n; i++) {
    if (i) ans += tree[1].len * ((long long)line[i].y - pre);
    update(M[line[i].l], M[line[i].r] - 1, 1, line[i].w);
    pre = (long long)line[i].y;
  }
  cout << ans << endl;
  return 0;
}
