#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 3e5 + 5;
map<int, vector<pair<int, int> > > X, Y;
struct point {
  long long t, x, y, z;
  point() { t = x = y = z = 0; }
  point(long long a, long long b, long long c, long long d) {
    t = a, x = b, y = c, z = d;
  }
  bool operator<(const point &b) const {
    return make_pair(y, t) < make_pair(b.y, b.t);
  }
};
vector<point> a;
long long fenwick[M];
void upd(long long node, long long v) {
  while (node < M) {
    fenwick[node] += v;
    node += node & (-node);
  }
}
long long query(long long node) {
  long long ans = 0;
  while (node) {
    ans += fenwick[node];
    node -= node & (-node);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, ans = 0;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a == c) {
      X[a].push_back({min(b, d), 0});
      X[a].push_back({max(b, d), 1});
    } else {
      Y[b].push_back({min(a, c), 0});
      Y[b].push_back({max(a, c), 1});
    }
  }
  for (auto &ele : X) {
    auto &v = ele.second;
    sort(v.begin(), v.end());
    long long prv = -1, cnt = 0;
    for (auto &pos : v) {
      if (pos.second == 0) {
        cnt++;
        if (cnt == 1) prv = pos.first;
      } else {
        if (cnt == 1) {
          a.emplace_back(point(0, ele.first, prv, -1));
          a.emplace_back(point(2, ele.first, pos.first, -1));
          ans += pos.first - prv + 1;
        }
        cnt--;
      }
    }
  }
  for (auto &ele : Y) {
    auto &v = ele.second;
    sort(v.begin(), v.end());
    long long prv = -1, cnt = 0;
    for (auto &pos : v) {
      if (pos.second == 0) {
        cnt++;
        if (cnt == 1) prv = pos.first;
      } else {
        if (cnt == 1) {
          a.emplace_back(point(1, prv, ele.first, pos.first));
          ans += pos.first - prv + 1;
        }
        cnt--;
      }
    }
  }
  sort(a.begin(), a.end());
  map<long long, long long> mp;
  for (auto &ele : a) {
    mp[ele.x];
    if (ele.t == 1) mp[ele.z];
  }
  long long cur = 0;
  for (auto &ele : mp) ele.second = ++cur;
  for (auto &ele : a) {
    ele.x = mp[ele.x];
    if (ele.t == 1) ele.z = mp[ele.z];
  }
  for (auto &ele : a) {
    if (ele.t == 0)
      upd(ele.x, 1);
    else if (ele.t == 2)
      upd(ele.x, -1);
    else
      ans -= query(ele.z) - query(ele.x - 1);
  }
  cout << ans;
}
