#include <bits/stdc++.h>
using namespace std;
const int Maxn = 200020;
vector<int> V;
int lx[Maxn], rx[Maxn], ly[Maxn], ry[Maxn];
long long a[Maxn << 3], b[Maxn << 3];
int tl[Maxn << 3];
int lz[Maxn << 3];
int get(int x) { return lower_bound(V.begin(), V.end(), x) - V.begin(); }
long long sum[Maxn << 1];
void push_up(int x) {
  a[x] = a[x << 1] + a[x << 1 | 1];
  tl[x] = min(tl[x << 1], tl[x << 1 | 1]);
  if (tl[x << 1] == tl[x << 1 | 1])
    b[x] = b[x << 1] + b[x << 1 | 1];
  else {
    if (tl[x << 1] < tl[x << 1 | 1])
      b[x] = b[x << 1];
    else
      b[x] = b[x << 1 | 1];
  }
}
void flip(int x, int w) {
  lz[x] += w;
  if (!tl[x]) {
    a[x] += b[x];
  }
  tl[x] += w;
  if (!tl[x]) {
    a[x] -= b[x];
  }
}
void push_down(int x) {
  if (lz[x]) {
    flip(x << 1, lz[x]);
    flip(x << 1 | 1, lz[x]);
    lz[x] = 0;
  }
}
void add(int L, int R, int w, int l, int r, int x) {
  if (L <= l && R >= r) {
    flip(x, w);
    return;
  }
  int mid = (l + r) >> 1;
  push_down(x);
  if (L <= mid) add(L, R, w, l, mid, x << 1);
  if (R > mid) add(L, R, w, mid + 1, r, x << 1 | 1);
  push_up(x);
}
void build(int l, int r, int x) {
  if (l == r) {
    b[x] = l == V.size() - 1 ? 1 : (V[l + 1] - V[l]);
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, x << 1);
  build(mid + 1, r, x << 1 | 1);
  push_up(x);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int xx1, yy1, xx2, yy2;
    scanf("%d%d%d%d", lx + i, ly + i, rx + i, ry + i);
    if (lx[i] == rx[i]) {
      if (ly[i] > ry[i]) swap(ly[i], ry[i]);
      V.push_back(ly[i]);
      V.push_back(ry[i]);
      V.push_back(ry[i] + 1);
    } else {
      if (lx[i] > rx[i]) swap(lx[i], rx[i]);
      V.push_back(ly[i]);
      V.push_back(ly[i] + 1);
    }
  }
  sort(V.begin(), V.end());
  V.erase(unique(V.begin(), V.end()), V.end());
  vector<pair<int, int> > V2;
  for (int i = 1; i <= n; i++) {
    ly[i] = get(ly[i]), ry[i] = get(ry[i]);
    V2.push_back(pair<int, int>(lx[i], i));
    V2.push_back(pair<int, int>(rx[i] + 1, -i));
  }
  sort(V2.begin(), V2.end());
  long long ans = 0;
  build(0, V.size() - 1, 1);
  for (int i = 0; i < V2.size(); i++) {
    int t1 = V2[i].first, t2 = V2[i].second;
    if (i) {
      ans += (long long)(t1 - V2[i - 1].first) * a[1];
    }
    int L = ly[abs(t2)], R = ry[abs(t2)];
    add(L, R, t2 > 0 ? 1 : -1, 0, V.size() - 1, 1);
  }
  printf("%lld\n", ans);
}
