#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
map<int, int> mpx, mpy;
int rmpx[N], rmpy[N];
struct Line {
  int x1, x2, y1, y2;
};
Line lines[N];
int BIT[N];
void update(int i, int v) {
  while (i < N) {
    BIT[i] += v;
    i += (i & -i);
  }
}
int query(int i) {
  int a = 0;
  while (i > 0) {
    a += BIT[i];
    i -= (i & -i);
  }
  return a;
}
vector<pair<int, int> > linex[N];
vector<pair<int, int> > liney[N];
vector<int> startPoints[N];
vector<int> endPoints[N];
vector<int> allx, ally;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d %d", &lines[i].x1, &lines[i].y1, &lines[i].x2,
          &lines[i].y2);
    if (lines[i].x1 > lines[i].x2) swap(lines[i].x1, lines[i].x2);
    if (lines[i].y1 > lines[i].y2) swap(lines[i].y1, lines[i].y2);
    allx.push_back(lines[i].x1);
    allx.push_back(lines[i].x2);
    ally.push_back(lines[i].y1);
    ally.push_back(lines[i].y2);
  }
  sort(allx.begin(), allx.end());
  sort(ally.begin(), ally.end());
  mpx[allx[0]] = 1;
  mpy[ally[0]] = 1;
  rmpx[mpx[allx[0]]] = allx[0];
  rmpy[mpy[ally[0]]] = ally[0];
  for (int i = 1; i < allx.size(); i++) {
    if (allx[i] != allx[i - 1]) mpx[allx[i]] = mpx[allx[i - 1]] + 1;
    if (ally[i] != ally[i - 1]) mpy[ally[i]] = mpy[ally[i - 1]] + 1;
    rmpx[mpx[allx[i]]] = allx[i];
    rmpy[mpy[ally[i]]] = ally[i];
  }
  for (int i = 1; i <= n; i++) {
    lines[i].x1 = mpx[lines[i].x1];
    lines[i].x2 = mpx[lines[i].x2];
    lines[i].y1 = mpy[lines[i].y1];
    lines[i].y2 = mpy[lines[i].y2];
    if (lines[i].x1 == lines[i].x2) {
      linex[lines[i].x1].push_back({lines[i].y1, lines[i].y2});
    } else {
      liney[lines[i].y1].push_back({lines[i].x1, lines[i].x2});
    }
  }
  n = 2 * n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    sort(linex[i].begin(), linex[i].end());
    sort(liney[i].begin(), liney[i].end());
    for (int j = 0; (j + 1) < linex[i].size();) {
      if (linex[i][j + 1].first <= linex[i][j].second) {
        linex[i][j].second = max(linex[i][j].second, linex[i][j + 1].second);
        linex[i].erase(linex[i].begin() + j + 1);
      } else
        j++;
    }
    for (int j = 0; (j + 1) < liney[i].size();) {
      if (liney[i][j + 1].first <= liney[i][j].second) {
        liney[i][j].second = max(liney[i][j].second, liney[i][j + 1].second);
        liney[i].erase(liney[i].begin() + j + 1);
      } else
        j++;
    }
    for (int j = 0; j < linex[i].size(); j++) {
      ans += rmpy[linex[i][j].second] - rmpy[linex[i][j].first] + 1;
    }
    for (int j = 0; j < liney[i].size(); j++) {
      ans += rmpx[liney[i][j].second] - rmpx[liney[i][j].first] + 1;
      startPoints[liney[i][j].first].push_back(i);
      endPoints[liney[i][j].second].push_back(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < startPoints[i].size(); j++) {
      update(startPoints[i][j], 1);
    }
    for (int j = 0; j < linex[i].size(); j++) {
      ans -= query(linex[i][j].second) - query(linex[i][j].first - 1);
    }
    for (int j = 0; j < endPoints[i].size(); j++) {
      update(endPoints[i][j], -1);
    }
  }
  cout << ans << endl;
}
