#include <bits/stdc++.h>
const int INF = 1e9 + 7;
struct node {
  int lo, hi, cnt;
  node *lp, *rp;
  node(int _lo, int _hi) {
    lo = _lo;
    hi = _hi;
    cnt = 0;
    lp = rp = nullptr;
  }
  int size() const { return hi - lo; }
  void update(int x, int v) {
    if (size() == 1)
      cnt += v;
    else if (x < lo + hi >> 1) {
      if (lp == nullptr) lp = new node(lo, lo + hi >> 1);
      lp->update(x, v);
      cnt += v;
    } else {
      if (rp == nullptr) rp = new node(lo + hi >> 1, hi);
      rp->update(x, v);
      cnt += v;
    }
  }
  int query(int x, int y) {
    if (y <= lo || x >= hi)
      return 0;
    else if (x <= lo && hi <= y)
      return cnt;
    else {
      int res = 0;
      if (lp != nullptr) res += lp->query(x, y);
      if (rp != nullptr) res += rp->query(x, y);
      return res;
    }
  }
} *root = new node(-INF, INF);
struct data {
  int index, left, right;
};
bool operator<(const data &lhs, const data &rhs) {
  if (lhs.index != rhs.index)
    return lhs.index < rhs.index;
  else
    return lhs.left < rhs.left;
}
int n;
long long ans;
std::vector<data> ver, hor;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 > x2)
      std::swap(x1, x2);
    else if (y1 > y2)
      std::swap(y1, y2);
    if (x1 == x2)
      ver.push_back({x1, y1, y2 + 1});
    else
      hor.push_back({y1, x1, x2 + 1});
  }
  std::sort(ver.begin(), ver.end());
  for (int i = 0, r, k = -INF; i < ver.size(); ++i) {
    if (ver[i].index != k) {
      k = ver[i].index;
      r = -INF;
    }
    if (r <= ver[i].right) {
      hor.push_back({std::max(r, ver[i].left), -INF, ver[i].index});
      hor.push_back({ver[i].right, -INF - 1, ver[i].index});
      ans += ver[i].right - std::max(r, ver[i].left);
      r = ver[i].right;
    }
  }
  std::sort(hor.begin(), hor.end());
  for (int i = 0, r, k = -INF; i < hor.size(); ++i)
    if (hor[i].left <= -INF)
      root->update(hor[i].right, (hor[i].left == -INF ? 1 : -1));
    else {
      if (hor[i].index != k) {
        k = hor[i].index;
        r = -INF;
      }
      if (r <= hor[i].right) {
        ans += hor[i].right - std::max(r, hor[i].left);
        ans -= root->query(std::max(r, hor[i].left), hor[i].right);
        r = hor[i].right;
      }
    }
  printf("%lld\n", ans);
  return 0;
}
