#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
long long bit[400001];
void add(int x, int v) {
  for (int i = x; i <= 400000; i += i & -i) bit[i] += v;
}
long long query(int x) {
  long long ret = 0;
  for (int i = x; i > 0; i -= i & -i) ret += bit[i];
  return ret;
}
long long ar[100001][4];
map<long long, long long> mx, my;
vector<pair<long long, long long> > horizontal[400001], vertical[400001];
vector<int> in[400001], out[400001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (4); ++j) cin >> ar[i][j];
    mx[ar[i][0]] = mx[ar[i][2]] = my[ar[i][1]] = my[ar[i][3]] = 1;
    if (ar[i][0] > ar[i][2]) swap(ar[i][0], ar[i][2]);
    if (ar[i][1] > ar[i][3]) swap(ar[i][1], ar[i][3]);
  }
  int c1 = 0, c2 = 0;
  for (auto &v : mx) {
    v.second = ++c1;
  }
  for (auto &v : my) {
    v.second = ++c2;
  }
  for (int i = (0); i < (n); ++i) {
    if (ar[i][0] == ar[i][2])
      horizontal[mx[ar[i][0]]].push_back(make_pair(ar[i][1], ar[i][3]));
    else
      vertical[my[ar[i][1]]].push_back(make_pair(ar[i][0], ar[i][2]));
  }
  long long res = 0;
  for (int i = 1; i <= c1; i++) {
    sort(horizontal[i].begin(), horizontal[i].end());
    if (horizontal[i].size() == 0) continue;
    int last = 0;
    for (int j = 1; j < horizontal[i].size(); j++) {
      if (horizontal[i][j].first <= horizontal[i][last].second) {
        horizontal[i][last].second =
            max(horizontal[i][last].second, horizontal[i][j].second);
      } else {
        res += horizontal[i][last].second - horizontal[i][last].first + 1;
        in[my[horizontal[i][last].first]].push_back(i);
        out[my[horizontal[i][last].second]].push_back(i);
        last = j;
      }
    }
    res += horizontal[i][last].second - horizontal[i][last].first + 1;
    in[my[horizontal[i][last].first]].push_back(i);
    out[my[horizontal[i][last].second]].push_back(i);
  }
  for (int i = 1; i <= c2; i++) {
    sort(vertical[i].begin(), vertical[i].end());
    for (int j = 0; j < in[i].size(); j++) {
      add(in[i][j], 1);
    }
    if (vertical[i].size() == 0) {
      for (int j = 0; j < out[i].size(); j++) {
        add(out[i][j], -1);
      }
      continue;
    }
    int last = 0;
    for (int j = 1; j < vertical[i].size(); j++) {
      if (vertical[i][j].first <= vertical[i][last].second) {
        vertical[i][last].second =
            max(vertical[i][last].second, vertical[i][j].second);
      } else {
        res += vertical[i][last].second - vertical[i][last].first + 1;
        res -= query(mx[vertical[i][last].second]) -
               query(mx[vertical[i][last].first] - 1);
        last = j;
      }
    }
    res += vertical[i][last].second - vertical[i][last].first + 1;
    res -= query(mx[vertical[i][last].second]) -
           query(mx[vertical[i][last].first] - 1);
    for (int j = 0; j < out[i].size(); j++) {
      add(out[i][j], -1);
    }
  }
  cout << res << endl;
}
