#include <bits/stdc++.h>
using namespace std;
const int N = 444444;
int n;
struct Line {
  long long x1, x2, h, cc;
  Line() {}
  Line(int x1, int x2, int h, int cc) : x1(x1), x2(x2), h(h), cc(cc) {}
  bool operator<(const Line &rhs) const { return h < rhs.h; }
} line[N];
vector<int> xindex;
struct Node {
  int cover;
  long long len;
} node[N << 2];
struct SegTree {
  void clear() { memset(node, 0, sizeof(node)); }
  void pushup(int p, int l, int r) {
    if (node[p].cover > 0) {
      node[p].len = xindex[r] - xindex[l];
    } else {
      if (r > l)
        node[p].len = node[((p) << 1)].len + node[((p) << 1 | 1)].len;
      else
        node[p].len = 0;
    }
  }
  void modify(int p, int l, int r, int L, int R, int cc) {
    if (L <= l && r <= R) {
      node[p].cover += cc;
      assert(node[p].cover >= 0);
      pushup(p, l, r);
      return;
    }
    int mid = (l + r) >> 1;
    if (L < mid) modify(((p) << 1), l, mid, L, R, cc);
    if (mid < R) modify(((p) << 1 | 1), mid, r, L, R, cc);
    pushup(p, l, r);
  }
} seg_tree;
int get_index(int x) {
  return lower_bound(xindex.begin(), xindex.end(), x) - xindex.begin();
}
void solve() {
  sort(line, line + 2 * n);
  sort(xindex.begin(), xindex.end());
  xindex.erase(unique(xindex.begin(), xindex.end()), xindex.end());
  int m = xindex.size();
  long long height = -(1LL << 60);
  long long ans = 0;
  seg_tree.clear();
  for (int i = 0; i < 2 * n; i++) {
    if (node[1].len > 0 && height < line[i].h) {
      ans += (long long)(line[i].h - height) * node[1].len;
    }
    height = line[i].h;
    int x = get_index(line[i].x1);
    int y = get_index(line[i].x2);
    assert(x != y);
    assert(x < m);
    assert(y < m);
    seg_tree.modify(1, 0, m - 1, get_index(line[i].x1), get_index(line[i].x2),
                    line[i].cc);
  }
  cout << ans << endl;
}
int main() {
  scanf("%d", &n);
  xindex.clear();
  for (int i = 0; i < n; i++) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 > x2) swap(x1, x2);
    if (y1 > y2) swap(y1, y2);
    line[i] = Line(x1, x2 + 1, y1, 1);
    line[i + n] = Line(x1, x2 + 1, y2 + 1, -1);
    xindex.push_back(x1);
    xindex.push_back(x2 + 1);
  }
  solve();
  return 0;
}
