#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
struct seg {
  int x, y, z, sgn;
};
bool cmp(seg A, seg B) { return A.y < B.y; }
const int maxn = 300001;
seg line[maxn * 2];
int X1, Y1, X2, Y2, a, b, c, d, n;
long long gg[maxn];
long long seg[maxn * 10], lap[maxn * 10];
long long hash_x[maxn * 2];
map<int, int> mpx;
inline void gao(int k, int l, int r) {
  int mid = (l + r) >> 1;
  if (lap[k])
    seg[k] = hash_x[r + 1] - hash_x[l];
  else {
    if (l == r)
      seg[k] = 0;
    else
      seg[k] = seg[k << 1] + seg[k << 1 | 1];
  }
}
void insert(int k, int l, int r, int ll, int rr, int x) {
  if (l == ll && rr == r) {
    lap[k] += x;
    gao(k, l, r);
    return;
  }
  int mid = (l + r) >> 1;
  if (rr <= mid)
    insert(k << 1, l, mid, ll, rr, x);
  else if (ll > mid)
    insert(k << 1 | 1, mid + 1, r, ll, rr, x);
  else {
    insert(k << 1, l, mid, ll, mid, x);
    insert(k << 1 | 1, mid + 1, r, mid + 1, rr, x);
  }
  gao(k, l, r);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &X1, &Y1, &X2, &Y2);
    a = min(X1, X2);
    a--;
    b = max(X1, X2);
    c = min(Y1, Y2);
    c--;
    d = max(Y1, Y2);
    mpx[a] = 1;
    mpx[b] = 1;
    line[i].x = a;
    line[i].y = c;
    line[i].z = b;
    line[i].sgn = 1;
    line[i + n].x = a;
    line[i + n].y = d;
    line[i + n].z = b;
    line[i + n].sgn = -1;
  }
  int cnt = 0;
  for (auto xx = mpx.begin(); xx != mpx.end(); xx++) {
    xx->second = ++cnt;
    hash_x[cnt] = xx->first;
  }
  sort(line + 1, line + 2 * n + 1, cmp);
  long long ans = 0;
  for (int i = 1; i <= 2 * n; i++) {
    int l = mpx[line[i].x];
    int r = mpx[line[i].z] - 1;
    if (l <= r) insert(1, 1, cnt, l, r, line[i].sgn);
    ans += 1ll * (1ll * line[i + 1].y - 1ll * line[i].y) * seg[1];
  }
  cout << ans << endl;
}
