#include <bits/stdc++.h>
using namespace std;
struct segment {
  int x, st, dr;
} sgm;
long long sol;
int n, i, j, k, nh, nv, kh, kv;
int X1, X2, Y1, Y2;
int ord[300005];
unordered_map<int, int> ump;
int aib[300005];
vector<segment> horiz, vert;
pair<int, int> pr;
set<pair<int, int> > fin;
bool cmp(segment a, segment b) {
  if (a.x == b.x) return a.st < b.st;
  return a.x < b.x;
}
bool cmpVert(segment a, segment b) { return a.st < b.st; }
void putInOrder(int x) {
  if (ump.count(x)) return;
  ump[x] = 0;
  ord[++k] = x;
}
void U(int pos, int val) {
  for (int i = pos; i <= k; i += (i & (-i))) aib[i] += val;
}
int Q(int pos) {
  int s = 0;
  for (int i = pos; i >= 1; i -= (i & (-i))) s += aib[i];
  return s;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &X1, &Y1, &X2, &Y2);
    if (X1 > X2) swap(X1, X2);
    if (Y1 > Y2) swap(Y1, Y2);
    if (X1 == X2) {
      sgm.x = X1;
      sgm.st = Y1;
      sgm.dr = Y2;
      vert.push_back(sgm);
      nv++;
    } else {
      sgm.x = Y1;
      sgm.st = X1;
      sgm.dr = X2;
      horiz.push_back(sgm);
      nh++;
    }
  }
  sort(vert.begin(), vert.end(), cmp);
  sort(horiz.begin(), horiz.end(), cmp);
  for (i = 1; i < nv; i++)
    if (i > 0 && vert[i].x == vert[i - 1].x)
      if (vert[i].st <= vert[i - 1].dr + 1) {
        vert[i - 1].dr = max(vert[i - 1].dr, vert[i].dr);
        vert.erase(vert.begin() + i);
        i--;
        nv--;
      }
  for (i = 1; i < nh; i++)
    if (i > 0 && horiz[i].x == horiz[i - 1].x)
      if (horiz[i].st <= horiz[i - 1].dr + 1) {
        horiz[i - 1].dr = max(horiz[i - 1].dr, horiz[i].dr);
        horiz.erase(horiz.begin() + i);
        i--;
        nh--;
      }
  for (i = 0; i < nv; i++) {
    sol += vert[i].dr - vert[i].st + 1;
    putInOrder(vert[i].x);
  }
  for (i = 0; i < nh; i++) {
    sol += horiz[i].dr - horiz[i].st + 1;
    putInOrder(horiz[i].st);
    putInOrder(horiz[i].dr);
  }
  sort(ord + 1, ord + k + 1);
  for (i = 1; i <= k; i++) ump[ord[i]] = i;
  for (i = 0; i < nv; i++) vert[i].x = ump[vert[i].x];
  for (i = 0; i < nh; i++)
    horiz[i].st = ump[horiz[i].st], horiz[i].dr = ump[horiz[i].dr];
  sort(vert.begin(), vert.end(), cmpVert);
  j = 0;
  for (i = 0; i < nh; i++) {
    while (j < nv && vert[j].st <= horiz[i].x) {
      U(vert[j].x, 1);
      fin.insert(make_pair(vert[j].dr, vert[j].x));
      j++;
    }
    while (!fin.empty()) {
      pr = *(fin.begin());
      if (pr.first >= horiz[i].x) break;
      U(pr.second, -1);
      fin.erase(pr);
    }
    sol -= Q(horiz[i].dr) - Q(horiz[i].st - 1);
  }
  printf("%I64d", sol);
  return 0;
}
