#include <bits/stdc++.h>
using namespace std;
int n, lx, ly, l, cnt[2 * 100005], len, aib[2 * 100005];
int v[2 * 100005], ll;
unordered_map<int, int> M;
struct el {
  int val, x, y;
  bool operator<(const el A) const {
    if (val == A.val) return x < A.x;
    return val < A.val;
  }
} Ox[100005], Oy[100005];
struct ev {
  int x, tip, st, dr;
  bool operator<(const ev &A) const {
    if (x == A.x) return tip < A.tip;
    return x < A.x;
  }
} Events[2 * 100005];
inline void Solve(el v[], int &n) {
  int m, i;
  if (!n) return;
  el aux[100005];
  sort(v + 1, v + n + 1);
  m = 1;
  aux[1] = v[1];
  for (i = 2; i <= n; ++i)
    if (v[i].val > aux[m].val)
      aux[++m] = v[i];
    else if (v[i].x <= aux[m].y)
      aux[m].y = max(aux[m].y, v[i].y);
    else
      aux[++m] = v[i];
  n = m;
  for (i = 1; i <= m; ++i) v[i] = aux[i];
}
inline void upd(int p, int val) {
  for (int i = p; i <= len; i += (i & (-i))) aib[i] += val;
}
inline int qry(int p) {
  int sol = 0;
  for (int i = p; i; i -= (i & (-i))) sol += aib[i];
  return sol;
}
inline void Normalize() {
  sort(v + 1, v + ll + 1);
  M[v[1]] = 1;
  for (int i = 2; i <= ll; ++i) {
    M[v[i]] = M[v[i - 1]];
    if (v[i] > v[i - 1]) ++M[v[i]];
  }
  len = M[v[ll]];
}
int main() {
  int i, j, x1, x2, y1, y2;
  long long sol = 0;
  cin.sync_with_stdio(0);
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 == x2) {
      ++lx;
      Ox[lx].val = x1;
      Ox[lx].x = min(y1, y2);
      Ox[lx].y = max(y1, y2);
      v[++ll] = y1;
      if (y1 != y2) v[++ll] = y2;
    } else {
      ++ly;
      Oy[ly].val = y1;
      Oy[ly].x = min(x1, x2);
      Oy[ly].y = max(x1, x2);
      v[++ll] = y1;
    }
  }
  Normalize();
  Solve(Ox, lx);
  Solve(Oy, ly);
  for (i = 1; i <= ly; ++i) {
    sol += Oy[i].y - Oy[i].x + 1;
    ++l;
    Events[l].x = Oy[i].x;
    Events[l].tip = 1;
    Events[l].st = Events[l].dr = Oy[i].val;
    ++l;
    Events[l].x = Oy[i].y + 1;
    Events[l].tip = 2;
    Events[l].st = Events[l].dr = Oy[i].val;
  }
  for (i = 1; i <= lx; ++i) {
    ++l;
    Events[l].x = Ox[i].val;
    Events[l].tip = 3;
    Events[l].st = Ox[i].x;
    Events[l].dr = Ox[i].y;
  }
  sort(Events + 1, Events + l + 1);
  for (i = 1; i <= l; ++i)
    if (Events[i].tip == 1) {
      if (++cnt[M[Events[i].st]] == 1) upd(M[Events[i].st], 1);
    } else if (Events[i].tip == 2) {
      if (--cnt[M[Events[i].st]] == 0) upd(M[Events[i].st], -1);
    } else
      sol += (Events[i].dr - Events[i].st + 1) -
             (qry(M[Events[i].dr]) - qry(M[Events[i].st] - 1));
  cout << sol << "\n";
  return 0;
}
