#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
template <class T>
inline bool Min(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
inline bool Max(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
inline int ni() {
  int a;
  scanf("%d", &a);
  return a;
}
inline void pi(int a) { printf("%d", a); }
inline ll nl() {
  ll a;
  scanf("%lld", &a);
  return a;
}
inline void pl(ll a) { printf("%lld", a); }
inline double nd() {
  double a;
  scanf("%lf", &a);
  return a;
}
inline void pd(double a) { printf("%.10lf", a); }
inline void sp() { putchar(' '); }
inline void en() { putchar('\n'); }
const ll inf = 1e10;
const ll sz = 1LL << 32;
const ll LEFT = 0;
const ll RIGHT = LEFT + sz - 1;
const int offs = 1e9 + 1;
struct Node {
  int sum = 0;
  int l = -1;
  int r = -1;
};
vector<Node> balance;
vector<Node> cnt;
void update(vector<Node> &xs, int pos) {
  Node &v = xs[pos];
  v.sum = 0;
  if (v.l != -1) v.sum += xs[v.l].sum;
  if (v.r != -1) v.sum += xs[v.r].sum;
}
int get_value(vector<Node> &xs, int pos, ll l, ll r, ll ql, ll qr) {
  if (pos < 0) return 0;
  if (ql > r || qr < l) return 0;
  if (ql <= l && r <= qr) return xs[pos].sum;
  ll mid = (l + r) / 2;
  int res = 0;
  res += get_value(xs, xs[pos].l, l, mid, ql, qr);
  res += get_value(xs, xs[pos].r, mid + 1, r, ql, qr);
  return res;
}
void add_value(vector<Node> &xs, int pos, int val, ll l, ll r, ll ql, ll qr) {
  if (ql > r || qr < l) return;
  if (ql <= l && r <= qr) {
    xs[pos].sum += val;
    return;
  }
  ll mid = (l + r) / 2;
  if (xs[pos].l == -1) xs[pos].l = (int)xs.size(), xs.push_back(Node());
  if (xs[pos].r == -1) xs[pos].r = (int)xs.size(), xs.push_back(Node());
  add_value(xs, xs[pos].l, val, l, mid, ql, qr);
  add_value(xs, xs[pos].r, val, mid + 1, r, ql, qr);
  update(xs, pos);
}
int get_value(vector<Node> &xs, ll l, ll r) {
  return get_value(xs, 0, LEFT, RIGHT, l + offs, r + offs);
}
void add_value(vector<Node> &xs, ll pos, int val) {
  add_value(xs, 0, val, LEFT, RIGHT, pos + offs, pos + offs);
}
int n;
map<int, vector<pii>> MapHor;
map<int, vector<pii>> MapVert;
ll scanline(vector<pii> &vec) {
  const int open = 1;
  vector<pii> xs;
  for (pii &num : vec) {
    xs.push_back(make_pair(num.first, open));
    xs.push_back(make_pair(num.second, open + 1));
  }
  sort((xs).begin(), (xs).end());
  ll len = 0;
  ll last = 0;
  int k = 0;
  for (int i = 0; i < xs.size(); i++) {
    if (xs[i].second == open) {
      k++;
      if (k == 1) last = xs[i].first;
    } else {
      k--;
      if (k == 0) len += 0LL + xs[i].first - last + 1;
    }
  }
  return len;
}
ll special_scanline(vector<pii> &vec) {
  const int open = 1;
  vector<pii> xs;
  for (pii &num : vec) {
    xs.push_back(make_pair(num.first, open));
    xs.push_back(make_pair(num.second, open + 1));
  }
  sort((xs).begin(), (xs).end());
  ll len = 0;
  ll last = 0;
  int k = 0;
  for (int i = 0; i < xs.size(); i++) {
    if (xs[i].second == open) {
      k++;
      if (k == 1) last = xs[i].first;
    } else {
      k--;
      if (k == 0) {
        len += get_value(cnt, last, xs[i].first);
      }
    }
  }
  return len;
}
void solve() {
  balance.push_back(Node());
  cnt.push_back(Node());
  n = ni();
  for (int i = 0; i < (int)(n); ++i) {
    int x1 = ni();
    int y1 = ni();
    int x2 = ni();
    int y2 = ni();
    if (x1 == x2) {
      MapVert[x2].push_back(make_pair(min(y1, y2), max(y1, y2)));
    } else {
      MapHor[y2].push_back(make_pair(min(x1, x2), max(x1, x2)));
    }
  }
  ll ans = 0;
  for (auto it : MapHor) ans += scanline(it.second);
  for (auto it : MapVert) ans += scanline(it.second);
  vector<pair<pii, int>> xs;
  const int open = 1;
  for (auto it : MapHor) {
    for (pii &cur : it.second) {
      xs.push_back(make_pair(make_pair(cur.first, 0), it.first));
      xs.push_back(make_pair(make_pair(cur.second, 2), it.first));
    }
  }
  for (auto it : MapVert) xs.push_back(make_pair(make_pair(it.first, 1), 0));
  sort((xs).begin(), (xs).end());
  for (int i = 0; i < (int)(xs.size()); ++i) {
    if (xs[i].first.second == 1) {
      ans -= special_scanline(MapVert.find(xs[i].first.first)->second);
    } else {
      int Y = xs[i].second;
      if (xs[i].first.second == 0) {
        add_value(balance, Y, 1);
        if (get_value(balance, Y, Y) == 1) add_value(cnt, Y, 1);
      } else {
        add_value(balance, Y, -1);
        if (get_value(balance, Y, Y) == 0) add_value(cnt, Y, -1);
      }
    }
  }
  pl(ans);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
