#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
int n;
struct node {
  int l, r;
  vector<int> vec;
} nd[4 * 200001];
void init(int l, int r, int i) {
  if (l == r) {
    nd[i].l = nd[i].r = l;
    return;
  }
  nd[i].l = l, nd[i].r = r;
  init(l, (r + l) / 2, i * 2);
  init((r + l) / 2 + 1, r, i * 2 + 1);
}
void upd(int l, int r, int x, int i) {
  if (l > nd[i].r || r < nd[i].l) return;
  if (l <= nd[i].l && r >= nd[i].r) {
    nd[i].vec.push_back(x);
    return;
  }
  upd(l, r, x, i * 2);
  upd(l, r, x, i * 2 + 1);
}
int solve(int p, int x, int i) {
  if (p > nd[i].r || p < nd[i].l) return 0;
  if (nd[i].r == nd[i].l) {
    int ret = upper_bound((nd[i].vec).begin(), (nd[i].vec).end(), x) -
              nd[i].vec.begin();
    return ret;
  }
  int l = solve(p, x, i * 2);
  int r = solve(p, x, i * 2 + 1);
  int ret = upper_bound((nd[i].vec).begin(), (nd[i].vec).end(), x) -
            nd[i].vec.begin();
  return ret + l + r;
}
int X1[200001], Y1[200001], X2[200001], Y2[200001];
map<int, int> mpX, mpY, rmpX, rmpY;
vector<int> X, Y;
vector<pair<int, pair<int, int> > > Hor, Ver, Hor2, Ver2;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
    X.push_back(X1[i]);
    X.push_back(X2[i]);
    Y.push_back(Y1[i]);
    Y.push_back(Y2[i]);
  }
  sort((X).begin(), (X).end());
  (X).resize(unique((X).begin(), (X).end()) - (X).begin());
  sort((Y).begin(), (Y).end());
  (Y).resize(unique((Y).begin(), (Y).end()) - (Y).begin());
  for (int i = 0; i < X.size(); i++) {
    mpX[X[i]] = i;
    rmpX[i] = X[i];
  }
  for (int i = 0; i < Y.size(); i++) {
    mpY[Y[i]] = i;
    rmpY[i] = Y[i];
  }
  for (int i = 0; i < n; i++) {
    X1[i] = mpX[X1[i]];
    X2[i] = mpX[X2[i]];
    Y1[i] = mpY[Y1[i]];
    Y2[i] = mpY[Y2[i]];
    if (X1[i] == X2[i]) {
      Ver.push_back(
          make_pair(X1[i], make_pair(min(Y1[i], Y2[i]), max(Y1[i], Y2[i]))));
    } else {
      Hor.push_back(
          make_pair(Y1[i], make_pair(min(X1[i], X2[i]), max(X1[i], X2[i]))));
    }
  }
  sort((Hor).begin(), (Hor).end()), sort((Ver).begin(), (Ver).end());
  for (int i = 0; i < Hor.size(); i++) {
    int i2 = i;
    while (i2 < Hor.size() && Hor[i].first == Hor[i2].first) i2++;
    for (int j = i; j < i2; j++) {
      int j2 = j + 1, ed = Hor[j].second.second;
      while (j2 < i2 && ed >= Hor[j2].second.first) {
        ed = max(ed, Hor[j2].second.second);
        j2++;
      }
      Hor2.push_back(
          make_pair(Hor[j].first, make_pair(Hor[j].second.first, ed)));
      j = j2 - 1;
    }
    i = i2 - 1;
  }
  for (int i = 0; i < Ver.size(); i++) {
    int i2 = i;
    while (i2 < Ver.size() && Ver[i].first == Ver[i2].first) i2++;
    for (int j = i; j < i2; j++) {
      int j2 = j, ed = Ver[j].second.second;
      while (j2 < i2 && ed >= Ver[j2].second.first) {
        ed = max(ed, Ver[j2].second.second);
        j2++;
      }
      Ver2.push_back(
          make_pair(Ver[j].first, make_pair(Ver[j].second.first, ed)));
      j = j2 - 1;
    }
    i = i2 - 1;
  }
  long long ans = 0;
  for (int i = 0; i < Ver2.size(); i++) {
    int L = rmpY[Ver2[i].second.first], R = rmpY[Ver2[i].second.second];
    ans += abs(R - L) + 1;
  }
  for (int i = 0; i < Hor2.size(); i++) {
    int L = rmpX[Hor2[i].second.first], R = rmpX[Hor2[i].second.second];
    ans += abs(R - L) + 1;
  }
  init(0, mpX.size() - 1, 1);
  for (int i = 0; i < Hor2.size(); i++) {
    upd(Hor2[i].second.first, Hor2[i].second.second, Hor2[i].first, 1);
  }
  for (int i = 0; i < 4 * 50; i++) sort((nd[i].vec).begin(), (nd[i].vec).end());
  for (int i = 0; i < Ver2.size(); i++) {
    int r = solve(Ver2[i].first, Ver2[i].second.second, 1);
    int l = solve(Ver2[i].first, Ver2[i].second.first - 1, 1);
    ans -= r - l;
  }
  cout << ans << endl;
  return 0;
}
