#include <bits/stdc++.h>
using namespace std;
int BIT[500007], cntx, cnty, N, hx[500007], hy[500007];
long long res;
vector<pair<int, int> > b[500007], sx[500007], sy[500007];
vector<int> e[500007];
struct Info {
  int x1, y1, x2, y2;
} seg[500007];
void Add(int x, int y) {
  while (x <= cntx) {
    BIT[x] += y;
    x += x & (-x);
  }
}
int Query(int x) {
  int res = 0;
  while (x) {
    res += BIT[x];
    x -= x & (-x);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> seg[i].x1 >> seg[i].y1 >> seg[i].x2 >> seg[i].y2;
    if (seg[i].x1 > seg[i].x2) swap(seg[i].x1, seg[i].x2);
    if (seg[i].y1 > seg[i].y2) swap(seg[i].y1, seg[i].y2);
    hx[++cntx] = seg[i].x1;
    hx[++cntx] = seg[i].x2;
    hy[++cnty] = seg[i].y1;
    hy[++cnty] = seg[i].y2;
  }
  sort(hx + 1, hx + cntx + 1);
  sort(hy + 1, hy + cnty + 1);
  cntx = unique(hx + 1, hx + cntx + 1) - hx - 1;
  cnty = unique(hy + 1, hy + cnty + 1) - hy - 1;
  for (int i = 1; i <= N; i++) {
    if (seg[i].x1 == seg[i].x2) {
      int x = lower_bound(hx + 1, hx + cntx + 1, seg[i].x1) - hx;
      sx[x].push_back(make_pair(seg[i].y1, seg[i].y2));
    } else {
      int y = lower_bound(hy + 1, hy + cnty + 1, seg[i].y1) - hy;
      sy[y].push_back(make_pair(seg[i].x1, seg[i].x2));
    }
  }
  for (int i = 1; i <= cntx; i++) {
    sort(sx[i].begin(), sx[i].end());
    int j;
    for (j = 0; j < sx[i].size(); j++) {
      int k = j, cur = sx[i][j].second;
      while (k < sx[i].size() && sx[i][k].first <= cur) {
        cur = max(cur, sx[i][k].second);
        k++;
      }
      int y = lower_bound(hy + 1, hy + cnty + 1, sx[i][j].first) - hy;
      e[y].push_back(i);
      y = lower_bound(hy + 1, hy + cnty + 1, cur) - hy;
      e[y + 1].push_back(-i);
      res += cur - sx[i][j].first + 1;
      j = k - 1;
    }
  }
  for (int i = 1; i <= cnty; i++) {
    sort(sy[i].begin(), sy[i].end());
    int j;
    for (j = 0; j < sy[i].size(); j++) {
      int k = j, cur = sy[i][j].second;
      while (k < sy[i].size() && sy[i][k].first <= cur) {
        cur = max(cur, sy[i][k].second);
        k++;
      }
      b[i].push_back(make_pair(sy[i][j].first, cur));
      j = k - 1;
    }
  }
  for (int i = 1; i <= cnty; i++) {
    for (int j = 0; j < e[i].size(); j++) {
      if (e[i][j] > 0)
        Add(e[i][j], 1);
      else
        Add(-e[i][j], -1);
    }
    for (int j = 0; j < b[i].size(); j++) {
      int lx = lower_bound(hx + 1, hx + cntx + 1, b[i][j].first) - hx;
      int rx = lower_bound(hx + 1, hx + cntx + 1, b[i][j].second) - hx;
      res += b[i][j].second - b[i][j].first + 1 - (Query(rx) - Query(lx - 1));
    }
  }
  cout << res << endl;
}
