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