#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 100;
int n, a1, b1, a2, b2, a[maxn], res;
int main() {
  while (~scanf("%d", &n) && n) {
    long long ans = 0;
    res = 0;
    while (n--) {
      scanf("%d%d%d%d", &a1, &b1, &a2, &b2);
      if (a1 + b1 < a2 + b2) {
        if (a1 > b2)
          ans += a1 - b2;
        else if (b1 > a2)
          ans += a2 - b1;
      } else
        ans += a1 + a2, a[res++] = a1 + b1, a[res++] = a2 + b2;
    }
    sort(a, a + res);
    for (register int i = 0; i < res; i += 2) ans -= a[i];
    printf("%I64d\n", ans);
  }
  return 0;
}
