#include <bits/stdc++.h>
using namespace std;
int cnt;
int y[500005];
struct node {
  int l, r, cnt;
  int m;
} E[500005 << 2];
struct Scan {
  int x, y1, y2;
  int cnt;
  bool flag;
} line[500005 << 1];
void build(int l, int r, int t) {
  E[t].l = l;
  E[t].r = r;
  E[t].m = 0;
  E[t].cnt = 0;
  if (E[t].l + 1 == E[t].r) return;
  int mid = (l + r) >> 1;
  build(l, mid, t << 1);
  build(mid, r, t << 1 | 1);
}
void update_m(int t) {
  if (E[t].cnt) {
    E[t].m = y[E[t].r] - y[E[t].l];
  } else if (E[t].l + 1 == E[t].r) {
    E[t].m = 0;
  } else {
    E[t].m = E[t << 1].m + E[t << 1 | 1].m;
  }
}
void update(int l, int r, int t, int z) {
  if (y[E[t].l] == l && y[E[t].r] == r) {
    E[t].cnt += z;
    update_m(t);
    return;
  }
  if (E[t].l + 1 < E[t].r) {
    int mid = (E[t].l + E[t].r) >> 1;
    if (r <= y[mid])
      update(l, r, t << 1, z);
    else if (l >= y[mid])
      update(l, r, t << 1 | 1, z);
    else {
      update(l, y[mid], t << 1, z);
      update(y[mid], r, t << 1 | 1, z);
    }
  }
  update_m(t);
}
void add(int x, int y1, int y2, int yy, int f) {
  line[cnt].x = x;
  line[cnt].y1 = y1;
  line[cnt].y2 = y2;
  line[cnt].flag = f;
  y[cnt++] = yy;
}
bool cmp(Scan a, Scan b) {
  if (a.x == b.x) return a.flag > b.flag;
  return a.x < b.x;
}
int main() {
  int n, cases = 0;
  int x1, x2, y1, y2;
  while (~scanf("%d", &n) && n) {
    cnt = 0;
    while (n--) {
      scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
      if (x1 > x2) swap(x1, x2);
      if (y1 > y2) swap(y1, y2);
      x2++;
      y2++;
      add(x1, y1, y2, y1, 1);
      add(x2, y1, y2, y2, 0);
    }
    sort(y, y + cnt);
    sort(line, line + cnt, cmp);
    int uni_cnt = unique(y, y + cnt) - y;
    build(0, uni_cnt - 1, 1);
    long long ans = 0, now_m = 0;
    for (int i = 0; i < cnt; i++) {
      if (line[i].flag) {
        update(line[i].y1, line[i].y2, 1, 1);
      } else {
        update(line[i].y1, line[i].y2, 1, -1);
      }
      if (i) ans += now_m * (line[i].x - line[i - 1].x);
      now_m = E[1].m;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
