#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
inline bool mina(A &first, B second) {
  return (first > second) ? (first = second, 1) : 0;
}
template <class A, class B>
inline bool maxa(A &first, B second) {
  return (first < second) ? (first = second, 1) : 0;
}
template <class T>
class IntervalSet {
 public:
  set<pair<T, T>> S;
  IntervalSet() {}
  IntervalSet(vector<pair<T, T>> &v) {
    for (auto e : v) {
      assert(e.first < e.second);
      S.insert(e);
    }
  }
  pair<T, T> get_intersection() {
    assert(((int)(S).size()) > 0);
    pair<T, T> ret = *S.begin();
    for (auto e : S) {
      ret.first = max(ret.first, e.first);
      ret.second = min(ret.second, e.second);
    }
    return ret;
  }
  long long length() {
    long long ret = 0;
    for (auto e : S) ret += e.second - e.first;
    return ret;
  }
  void union_intervals() {
    if (((int)(S).size()) == 0) return;
    vector<pair<T, int>> events;
    for (auto e : S) {
      events.push_back(make_pair(e.first, -1));
      events.push_back(make_pair(e.second, 1));
    }
    S.clear();
    sort(events.begin(), events.end());
    int open_interval = 1;
    T last_open = events[0].first;
    for (int i = 1; i < ((int)(events).size()); i++) {
      if (!open_interval) last_open = events[i].first;
      open_interval -= events[i].second;
      if (!open_interval) S.insert(pair<T, T>(last_open, events[i].first));
    }
  }
  void add(T a, T b) {
    assert(a < b);
    pair<T, T> inter = pair<T, T>(a, b);
    if (!S.empty()) {
      auto it1 = S.lower_bound(pair<T, T>(inter.first, inter.first));
      if (it1 != S.begin()) {
        auto it2 = it1;
        it2--;
        if (it2->second >= inter.first) {
          inter = union_overlap(inter, *it2);
          S.erase(it2);
        }
      }
      while (it1 != S.end()) {
        if (inter.second < it1->first) break;
        inter = union_overlap(inter, *it1);
        auto temp = it1;
        temp++;
        S.erase(it1);
        it1 = temp;
      }
    }
    S.insert(inter);
  }
  void print() {
    cout << "{";
    for (auto e : S) cout << " (" << e.first << "," << e.second << ")";
    cout << " }" << endl;
  }

 private:
  pair<T, T> union_overlap(pair<T, T> a, pair<T, T> b) {
    return pair<T, T>(min(a.first, b.first), max(a.second, b.second));
  }
};
const int MAXN = 1e5 + 5;
int N;
map<int, vector<pair<int, int>>> verticals;
map<int, vector<pair<int, int>>> horizontals;
struct Info {
  int first;
  int y1, y2;
  int left;
  Info() {}
  Info(int a, int b, int c, int d) {
    first = a;
    y1 = b;
    y2 = c;
    left = d;
  }
};
vector<Info> events;
int fenwick[3 * MAXN];
void update(int first, int val) {
  for (int i = first; i <= N; i += (i & (-i))) fenwick[i] += val;
}
int query(int first) {
  int res = 0;
  for (int i = first; i; i -= (i & (-i))) res += fenwick[i];
  return res;
}
bool cmp1(Info &a, Info &b) {
  if (a.first != b.first) return a.first < b.first;
  if (a.left != b.left) return a.left > b.left;
  return false;
}
int main() {
  scanf("%d", &N);
  int x1, y1, x2, y2;
  for (int(i) = 0; (i) < (N); ++(i)) {
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      if (y1 > y2) swap(y1, y2);
      verticals[x1].push_back(pair<int, int>(y1, y2 + 1));
    } else {
      if (x1 > x2) swap(x1, x2);
      horizontals[y1].push_back(pair<int, int>(x1, x2 + 1));
    }
  }
  long long ans = 0;
  map<int, int> mapy;
  for (auto it = verticals.begin(); it != verticals.end(); it++) {
    IntervalSet<int> solver;
    for (auto p : it->second) {
      solver.add(p.first, p.second);
    }
    for (auto p : solver.S) {
      events.push_back(Info(it->first, p.first, p.second, -1));
      mapy[p.first]++;
      mapy[p.second]++;
    }
    ans += solver.length();
  }
  for (auto it = horizontals.begin(); it != horizontals.end(); it++) {
    IntervalSet<int> solver;
    for (auto p : it->second) {
      solver.add(p.first, p.second);
    }
    for (auto p : solver.S) {
      events.push_back(Info(p.first, it->first, 0, 1));
      events.push_back(Info(p.second, it->first, 0, 0));
      mapy[it->first]++;
    }
    ans += solver.length();
  }
  N = 0;
  for (auto it = mapy.begin(); it != mapy.end(); it++) {
    it->second = ++N;
  }
  sort(events.begin(), events.end(), cmp1);
  for (auto &e : events) {
    if (e.left == 1) {
      update(mapy[e.y1], 1);
    } else if (e.left == 0) {
      update(mapy[e.y1], -1);
    } else {
      ans -= query(mapy[e.y2] - 1) - query(mapy[e.y1] - 1);
    }
  }
  cout << ans << endl;
  return 0;
}
