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