#include <bits/stdc++.h>
using namespace std;
int read(int &n) { return scanf(" %d ", &n); }
int read(long long &n) { return scanf(" %lld ", &n); }
int read(unsigned long long &n) { return scanf(" %llu ", &n); }
int read(double &n) { return scanf(" %lf ", &n); }
int read(char *c) { return scanf(" %s ", c); }
struct Edge {
  bool open;
  int x, yMin, yMax;
  Edge(int x, int y1, int y2, bool op) {
    this->x = x;
    yMin = y1, yMax = y2;
    open = op;
  }
  bool operator<(const Edge &e) const { return (x < e.x); }
};
int n, m, h[100010 << 1];
int sum[100010 << 5], counter[100010 << 5];
vector<Edge> edges;
void update(int p, int l, int r, int yMin, int yMax, bool open) {
  if (h[r] < yMin || yMax < h[l]) return;
  int c = p << 1, mid = (l + r) >> 1;
  if (yMin <= h[l] && h[r] <= yMax) {
    counter[p] += open ? 1 : -1;
    if (counter[p])
      sum[p] = h[r] - h[l];
    else
      sum[p] = sum[c] + sum[c + 1];
    return;
  }
  if (l + 1 >= r) return;
  update(c, l, mid, yMin, yMax, open);
  update(c + 1, mid, r, yMin, yMax, open);
  if (counter[p])
    sum[p] = h[r] - h[l];
  else
    sum[p] = sum[c] + sum[c + 1];
}
long long solve() {
  sort(h + 1, h + m + 1);
  int k = 1;
  for (int i = 2; i <= m; i++)
    if (h[i] != h[k]) h[++k] = h[i];
  m = k;
  for (int i = 0, lm = 100010 << 4; i < lm; i++) sum[i] = 0, counter[i] = 0;
  long long area = 0LL;
  sort(edges.begin(), edges.end());
  update(1, 1, m, edges[0].yMin, edges[0].yMax, edges[0].open);
  for (int i = 1; i < edges.size(); i++) {
    area += sum[1] * (long long)(edges[i].x - edges[i - 1].x);
    update(1, 1, m, edges[i].yMin, edges[i].yMax, edges[i].open);
  }
  return area;
}
int main() {
  int caseNo = 1, cases = 0;
  long long x1, y1, x2, y2;
  while (caseNo--) {
    read(n);
    edges.clear();
    m = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%lld %lld %lld %lld", &x1, &y1, &x2, &y2);
      x1 += (1e9);
      y1 += (1e9);
      x2 += (1e9);
      y2 += (1e9);
      if (x1 > x2) swap(x1, x2);
      if (y1 > y2) swap(y1, y2);
      --x1;
      --y1;
      edges.push_back(Edge(x1, y1, y2, true));
      edges.push_back(Edge(x2, y1, y2, false));
      h[++m] = y1;
      h[++m] = y2;
    }
    printf("%lld\n", solve());
  }
  return 0;
}
