#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const long double pi = acos(-1);
struct BIT {
  int N;
  vector<int> v;
  BIT(int n) : N(n), v(n + 1) {}
  int sum(int i) {
    int s = 0;
    for (; i > 0; s += v[i], i -= i & -i)
      ;
    return s;
  }
  void add(int i, int x) {
    for (; i <= N; v[i] += x, i += i & -i)
      ;
  }
};
struct Line {
  int x1, y1, x2, y2;
} A[100100];
const int HOR = 0;
const int VER = 1;
struct event {
  int x;
  int type;
  int open;
  int cmp;
  int y, y1, y2;
};
int mycompare(const event& e1, const event& e2) {
  if (e1.x != e2.x) return e1.x < e2.x;
  return e1.cmp < e2.cmp;
}
int N;
vector<int> nums;
vector<pair<int, int> > hor[200100];
vector<pair<int, int> > ver[200100];
inline int gi(int i) {
  return (int)(lower_bound(nums.begin(), nums.end(), i) - nums.begin());
}
void rem_dup(vector<pair<int, int> >& vec) {
  if (int((vec).size()) == 0) return;
  vector<pair<int, int> > events;
  for (int(i) = 0; (i) < (int((vec).size())); (i)++)
    events.push_back(make_pair(vec[i].first, -1));
  for (int(i) = 0; (i) < (int((vec).size())); (i)++)
    events.push_back(make_pair(vec[i].second, 1));
  sort(events.begin(), events.end());
  vec.clear();
  for (int i = 0, cnt = 0, op; i < int((events).size()); i++) {
    if (cnt == 1 && events[i].second == 1) {
      vec.push_back(make_pair(op, events[i].first));
    }
    if (cnt == 0 && events[i].second == -1) {
      op = events[i].first;
    }
    cnt -= events[i].second;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout << fixed;
  cout.tie(0);
  cin.tie(0);
  cin >> N;
  for (int(i) = 1; (i) <= (N); (i)++)
    cin >> A[i].x1 >> A[i].y1 >> A[i].x2 >> A[i].y2;
  for (int(i) = 1; (i) <= (N); (i)++)
    if (A[i].x1 > A[i].x2) swap(A[i].x1, A[i].x2);
  for (int(i) = 1; (i) <= (N); (i)++)
    if (A[i].y1 > A[i].y2) swap(A[i].y1, A[i].y2);
  for (int(i) = 1; (i) <= (N); (i)++) nums.push_back(A[i].x1);
  for (int(i) = 1; (i) <= (N); (i)++) nums.push_back(A[i].y1);
  for (int(i) = 1; (i) <= (N); (i)++) nums.push_back(A[i].x2);
  for (int(i) = 1; (i) <= (N); (i)++) nums.push_back(A[i].y2);
  nums.push_back((int)(-2e9));
  sort(nums.begin(), nums.end());
  nums.erase(unique(nums.begin(), nums.end()), nums.end());
  for (int(i) = 1; (i) <= (N); (i)++) {
    if (A[i].x1 == A[i].x2) {
      ver[gi(A[i].x1)].push_back(make_pair(A[i].y1, A[i].y2));
    } else {
      hor[gi(A[i].y1)].push_back(make_pair(A[i].x1, A[i].x2));
    }
  }
  for (int(i) = 0; (i) < (200100); (i)++) rem_dup(ver[i]);
  for (int(i) = 0; (i) < (200100); (i)++) rem_dup(hor[i]);
  long long ans = 0;
  for (int(i) = 0; (i) < (200100); (i)++)
    for (int(j) = 0; (j) < (int((ver[i]).size())); (j)++)
      ans += ver[i][j].second - ver[i][j].first + 1;
  for (int(i) = 0; (i) < (200100); (i)++)
    for (int(j) = 0; (j) < (int((hor[i]).size())); (j)++)
      ans += hor[i][j].second - hor[i][j].first + 1;
  vector<event> events;
  for (int(i) = 0; (i) < (200100); (i)++)
    for (int(j) = 0; (j) < (int((ver[i]).size())); (j)++) {
      event ev;
      ev.x = i;
      ev.type = VER;
      ev.y1 = gi(ver[i][j].first);
      ev.y2 = gi(ver[i][j].second);
      ev.cmp = 2;
      events.push_back(ev);
    }
  for (int(i) = 0; (i) < (200100); (i)++)
    for (int(j) = 0; (j) < (int((hor[i]).size())); (j)++) {
      event op;
      op.type = HOR;
      op.open = 1;
      op.x = gi(hor[i][j].first);
      op.y = i;
      op.cmp = 1;
      events.push_back(op);
      event cl;
      cl.type = HOR;
      cl.open = 0;
      cl.x = gi(hor[i][j].second);
      cl.y = i;
      cl.cmp = 3;
      events.push_back(cl);
    }
  sort(events.begin(), events.end(), mycompare);
  BIT bit(200100);
  for (int(i) = 0; (i) < (int((events).size())); (i)++) {
    event ev = events[i];
    if (ev.type == HOR) {
      if (ev.open) {
        bit.add(ev.y, 1);
      } else {
        bit.add(ev.y, -1);
      }
    } else {
      ans -= bit.sum(ev.y2) - bit.sum(ev.y1 - 1);
    }
  }
  cout << ans << '\n';
}
