#include <bits/stdc++.h>
using namespace std;
int tree[300000 + 5];
map<int, vector<pair<int, int>>> hori, vert;
map<int, int> mp;
vector<int> startingPoints[300000 + 5], endingPoints[300000 + 5];
vector<pair<int, int>> verticalIntervals[300000 + 5];
int read(int *bit, int idx) {
  int sum = 0;
  if (idx == 0) return 0;
  while (idx > 0) {
    sum += bit[idx];
    idx -= (idx & -idx);
  }
  return sum;
}
void update(int *bit, int idx, int val) {
  while (idx <= 300000) {
    bit[idx] += val;
    idx += (idx & -idx);
  }
}
int rangeQuery(int *bit, int i, int j) {
  return read(bit, j) - read(bit, i - 1);
}
vector<pair<int, int>> mergeIntervals(vector<pair<int, int>> V) {
  sort(V.begin(), V.end());
  vector<pair<int, int>> ans;
  ans.clear();
  int last = V[0].second, start = V[0].first;
  for (int i = 1; i < V.size(); ++i) {
    if (V[i].first <= last) {
      last = max(last, V[i].second);
    } else {
      ans.push_back({start, last});
      start = V[i].first;
      last = V[i].second;
      assert(start <= last);
    }
  }
  ans.push_back({start, last});
  return ans;
}
int main() {
  signed long long int ans = 0;
  int p = 0;
  int N, x1, x2, y1, y2;
  vector<int> comp;
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &x1);
    scanf("%d", &y1);
    scanf("%d", &x2);
    scanf("%d", &y2);
    assert(x1 == x2 or y1 == y2);
    if (x1 == x2) {
      if (y1 > y2) swap(y1, y2);
      vert[x1].push_back({y1, y2});
    } else {
      if (x1 > x2) swap(x1, x2);
      hori[y1].push_back({x1, x2});
    }
    comp.push_back(x1);
    comp.push_back(x2);
    comp.push_back(y1);
    comp.push_back(y2);
  }
  sort(comp.begin(), comp.end());
  for (int i = 0; i < comp.size(); ++i) {
    if (mp[comp[i]] == 0) {
      mp[comp[i]] = ++p;
    }
  }
  for (auto it : hori) {
    int y = mp[it.first];
    vector<pair<int, int>> temp = mergeIntervals(it.second);
    for (int i = 0; i < temp.size(); ++i) {
      ans += temp[i].second - temp[i].first + 1;
      int x1 = mp[temp[i].first];
      int x2 = mp[temp[i].second];
      startingPoints[x1].push_back(y);
      endingPoints[x2].push_back(y);
    }
  }
  for (auto it : vert) {
    vector<pair<int, int>> temp = mergeIntervals(it.second);
    int x = mp[it.first];
    for (int i = 0; i < temp.size(); ++i) {
      ans += temp[i].second - temp[i].first + 1;
      int y1 = mp[temp[i].first];
      int y2 = mp[temp[i].second];
      verticalIntervals[x].push_back({y1, y2});
    }
  }
  for (int i = 1; i <= p; ++i) {
    for (int j = 0; j < startingPoints[i].size(); ++j) {
      update(tree, startingPoints[i][j], 1);
    }
    for (int j = 0; j < verticalIntervals[i].size(); ++j) {
      ans -= rangeQuery(tree, verticalIntervals[i][j].first,
                        verticalIntervals[i][j].second);
    }
    for (int j = 0; j < endingPoints[i].size(); ++j) {
      update(tree, endingPoints[i][j], -1);
    }
  }
  cout << ans;
}
