#include <bits/stdc++.h>
using namespace std;
int M, x1, x2, Y1, y2;
vector<pair<int, pair<int, int> > > horiz, vert, events;
long long CNT;
map<int, int> h;
vector<int> y;
long long AIB[400100], N;
inline int zeros(int x) { return x & (-x); }
inline void Add(int x, int q) {
  for (int i = x; i <= N; i += zeros(i)) AIB[i] += q;
}
inline long long comp(int x) {
  int ret = 0;
  for (int i = x; i > 0; i -= zeros(i)) ret += AIB[i];
  return ret;
}
vector<pair<int, pair<int, int> > > doIntervalStuff(
    vector<pair<int, pair<int, int> > > &a) {
  vector<pair<int, pair<int, int> > > ret;
  if (a.empty()) return ret;
  sort(a.begin(), a.end());
  int L = 0, R = 0, Y = 0;
  for (int i = 0; i < (int)a.size(); ++i) {
    if (i == 0 || a[i].first != a[i - 1].first) {
      if (i != 0) {
        ret.push_back(make_pair(Y, make_pair(L, R)));
        CNT += (R - L + 1);
      }
      Y = a[i].first;
      L = a[i].second.first;
      R = a[i].second.second;
      continue;
    }
    if (a[i].second.first > R + 1) {
      ret.push_back(make_pair(Y, make_pair(L, R)));
      CNT += (R - L + 1);
      L = a[i].second.first;
      R = a[i].second.second;
    } else {
      R = max(R, a[i].second.second);
    }
  }
  ret.push_back(make_pair(Y, make_pair(L, R)));
  CNT += (R - L + 1);
  return ret;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  scanf("%d", &M);
  for (int i = 1; i <= M; ++i) {
    scanf("%d%d%d%d", &x1, &Y1, &x2, &y2);
    if (x1 > x2) {
      swap(x1, x2);
    }
    if (Y1 > y2) {
      swap(Y1, y2);
    }
    if (x1 == x2) {
      vert.push_back(make_pair(x1, make_pair(Y1, y2)));
    } else {
      horiz.push_back(make_pair(Y1, make_pair(x1, x2)));
    }
  }
  vert = doIntervalStuff(vert);
  horiz = doIntervalStuff(horiz);
  for (auto x : vert) {
    y.push_back(x.second.first);
    y.push_back(x.second.second);
  }
  for (auto x : horiz) {
    y.push_back(x.first);
  }
  sort(y.begin(), y.end());
  y.erase(unique(y.begin(), y.end()), y.end());
  for (int i = 0; i < (int)y.size(); ++i) {
    h[y[i]] = i + 1;
  }
  N = y.size();
  for (auto x : horiz) {
    events.push_back(
        make_pair(x.second.first, make_pair(-1000000007, h[x.first])));
    events.push_back(
        make_pair(x.second.second, make_pair(1000000007, h[x.first])));
  }
  for (auto x : vert) {
    events.push_back(
        make_pair(x.first, make_pair(h[x.second.first], h[x.second.second])));
  }
  sort(events.begin(), events.end());
  for (auto e : events) {
    if (e.second.first == -1000000007) {
      Add(e.second.second, 1);
    } else if (e.second.first == 1000000007) {
      Add(e.second.second, -1);
    } else {
      CNT -= (comp(e.second.second) - comp(e.second.first - 1));
    }
  }
  cout << CNT;
  return 0;
}
