#include <bits/stdc++.h>
using namespace std;
long long T, n, x, y, p, q, i, s, a[222222];
int main() {
  scanf("%lld", &T);
  while (T--) {
    scanf("%lld%lld%lld%lld", &x, &y, &p, &q);
    if (x + y >= p + q) {
      a[++n] = x + y;
      a[++n] = p + q;
      s += x + p;
    } else if (x > q)
      s += x - q;
    else if (p < y)
      s += p - y;
  }
  sort(a + 1, a + 1 + n);
  for (i = 1; i <= n; i += 2) s -= a[i];
  printf("%lld", s);
}
