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