#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
int y[2 * maxn];
int sum[8 * maxn];
int cover[8 * maxn];
void update(int i, int L, int H, int l, int h, int v) {
  l = max(l, y[L]);
  h = min(h, y[H]);
  if (l >= h)
    return;
  else if (l == y[L] && h == y[H]) {
    cover[i] += v;
    if (cover[i] > 0)
      sum[i] = y[H] - y[L];
    else if (L + 1 >= H)
      sum[i] = 0;
    else
      sum[i] = sum[2 * i + 1] + sum[2 * i + 2];
  } else {
    int M = (L + H) / 2;
    update(2 * i + 1, L, M, l, h, v);
    update(2 * i + 2, M, H, l, h, v);
    if (cover[i] == 0) sum[i] = sum[2 * i + 1] + sum[2 * i + 2];
  }
}
struct Event {
  int x, yl, yh, v;
};
int main() {
  memset(sum, 0, sizeof(sum));
  memset(cover, 0, sizeof(cover));
  vector<Event> ve;
  int n, i;
  cin >> n;
  set<int> ys;
  for (i = 0; i < n; i++) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (a > c) swap(a, c);
    if (b > d) swap(b, d);
    c++, d++;
    ve.push_back({a, b, d, 1});
    ve.push_back({c, b, d, -1});
    ys.insert(b);
    ys.insert(d);
  }
  int ny = ys.size();
  i = 0;
  for (auto e : ys) {
    y[i++] = e;
  }
  auto comp = [](const Event& a, const Event& b) { return a.x < b.x; };
  sort(ve.begin(), ve.end(), comp);
  long long res = 0;
  long long prevx = 1e9 + 7;
  for (Event e : ve) {
    if (prevx != 1e9 + 7) res += (e.x - prevx) * sum[0];
    update(0, 0, ny - 1, e.yl, e.yh, e.v);
    prevx = e.x;
  }
  cout << res << endl;
  return 0;
}
