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