#include <bits/stdc++.h>
using namespace std;
vector<pair<int, pair<int, int> > > horz, vert, tmp;
set<int> y_com;
map<int, int> y_map;
void cleanup(vector<pair<int, pair<int, int> > >& v) {
  sort(v.begin(), v.end());
  for (auto it = v.begin(); it != v.end();) {
    if (it != v.begin()) {
      auto prev = it;
      prev--;
      if (prev->first == it->first &&
          prev->second.second >= it->second.first - 1) {
        prev->second.second = max(it->second.second, prev->second.second);
        it = v.erase(it);
      } else
        it++;
    } else
      it++;
  }
}
int BIT[211111];
void update(int pos, int val) {
  while (pos < 211111) {
    BIT[pos] += val;
    pos += (pos & (-pos));
  }
}
int get(int pos) {
  int ans = 0;
  while (pos > 0) {
    ans += BIT[pos];
    pos -= (pos & (-pos));
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x[2], y[2];
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    x[0] += 1000000001;
    x[1] += 1000000001;
    y[0] += 1000000001;
    y[1] += 1000000001;
    if (y[0] == y[1]) {
      horz.push_back(
          make_pair(y[0], make_pair(min(x[0], x[1]), max(x[0], x[1]))));
    } else {
      vert.push_back(
          make_pair(x[0], make_pair(min(y[0], y[1]), max(y[0], y[1]))));
    }
  }
  cleanup(horz);
  cleanup(vert);
  for (auto it : horz) {
    ans += it.second.second - it.second.first + 1;
    y_com.insert(it.first);
  }
  for (auto it : vert) {
    ans += it.second.second - it.second.first + 1;
    y_com.insert(it.second.first);
    y_com.insert(it.second.second);
  }
  int cnt = 1;
  for (auto it : y_com) y_map[it] = cnt++;
  for (auto it : horz) {
    tmp.push_back(make_pair(it.second.first, make_pair(it.first, 1)));
    tmp.push_back(make_pair(it.second.second + 1, make_pair(it.first, -1)));
  }
  sort(tmp.begin(), tmp.end());
  int cur = 0;
  for (auto it : vert) {
    while (cur < tmp.size() && tmp[cur].first <= it.first) {
      update(y_map[tmp[cur].second.first], tmp[cur].second.second);
      cur++;
    }
    ans -= get(y_map[it.second.second]) - get(y_map[it.second.first] - 1);
  }
  cout << ans << endl;
  return 0;
}
