#include <bits/stdc++.h>
using namespace std;
long long n, m, a1, b1, a2, b2, i, ans, a[200001];
int main() {
  scanf("%I64d\n", &n);
  for (i = 1; i <= n; i++) {
    scanf("%I64d%I64d%I64d%I64d\n", &a1, &b1, &a2, &b2);
    if (a1 + b1 == a2 + b2)
      ans += a1 - b2;
    else if (a1 + b1 > a2 + b2)
      ans += a1 + a2, a[++m] = a1 + b1, a[++m] = a2 + b2;
    else {
      if (a1 <= b2 && b1 <= a2) continue;
      if (a1 > b2)
        ans += a1 - b2;
      else
        ans += a2 - b1;
    }
  }
  sort(a + 1, a + m + 1);
  for (i = m - 1; i > 0; i -= 2) ans -= a[i];
  printf("%I64d", ans);
}
