#include <bits/stdc++.h>
using namespace std;
const int INF = 1500000000;
const int MOD = 1000000007;
const int HASH = 137;
const int NUM = 100005;
map<long long, vector<pair<long long, long long>>> vertical, horizontal;
struct BIT {
  long long N;
  vector<long long> A;
  BIT(long long N) : N(N) { A.resize(N + 1, 0); }
  inline long long lower_bit(long long x) { return x & -x; }
  long long sum(long long x) {
    long long s = 0;
    while (x > 0) {
      s += A[x];
      x -= lower_bit(x);
    }
    return s;
  }
  void add(long long x, long long d) {
    while (x <= N) {
      A[x] += d;
      x += lower_bit(x);
    }
  }
  long long query(long long a, long long b) {
    if (a > b) swap(a, b);
    return sum(b) - sum(a - 1);
  }
};
long long intersection() {
  vector<pair<long long, pair<long long, long long>>> event;
  vector<pair<long long, long long>> x;
  vector<long long> y;
  for (auto i : vertical) {
    long long now = i.first;
    for (auto j : i.second) {
      event.push_back(make_pair(now, make_pair(1, x.size())));
      x.push_back(j);
    }
  }
  for (auto i : horizontal) {
    for (auto j : i.second) {
      event.push_back(make_pair(j.first, make_pair(0, y.size())));
      event.push_back(make_pair(j.second, make_pair(2, y.size())));
    }
    y.push_back(i.first);
  }
  BIT master(y.size());
  long long ans = 0;
  sort(event.begin(), event.end());
  for (long long i = 0; i < event.size(); i++) {
    if (event[i].second.first == 0)
      master.add(event[i].second.second + 1, 1);
    else if (event[i].second.first == 2)
      master.add(event[i].second.second + 1, -1);
    else {
      long long a = distance(
          y.begin(),
          lower_bound(y.begin(), y.end(), x[event[i].second.second].first));
      if (a == y.size()) continue;
      long long b =
          distance(y.begin(), upper_bound(y.begin(), y.end(),
                                          x[event[i].second.second].second)) -
          1;
      if (b == -1) continue;
      if (a <= b) ans += master.query(a + 1, b + 1);
    }
  }
  return ans;
}
void MergeSegment(vector<pair<long long, long long>> &segment) {
  vector<pair<long long, long long>> merged;
  sort(segment.begin(), segment.end());
  for (long long i = 0, last = -INF; i < segment.size(); i++) {
    if (segment[i].first > last + 1)
      merged.push_back(segment[i]);
    else
      merged[merged.size() - 1].second = max(last, segment[i].second);
    last = max(last, segment[i].second);
  }
  segment = merged;
}
int main() {
  long long N;
  cin >> N;
  for (long long i = 0; i < N; i++) {
    long long x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 == x2)
      vertical[x1].push_back(make_pair(y1 < y2 ? y1 : y2, y1 > y2 ? y1 : y2));
    else
      horizontal[y1].push_back(make_pair(x1 < x2 ? x1 : x2, x1 > x2 ? x1 : x2));
  }
  for (auto &i : vertical) MergeSegment(i.second);
  for (auto &i : horizontal) MergeSegment(i.second);
  long long ans = 0;
  for (auto i : vertical)
    for (auto j : i.second) ans += j.second - j.first + 1;
  for (auto i : horizontal)
    for (auto j : i.second) ans += j.second - j.first + 1;
  cout << ans - intersection() << endl;
  return 0;
}
