#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int a[N][2], b[N][2], c[N];
int cnt;
long long ans;
int main() {
  int i, n;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &a[i][0], &b[i][0], &a[i][1], &b[i][1]);
    if (a[i][0] + b[i][0] >= a[i][1] + b[i][1]) {
      c[++cnt] = a[i][0] + b[i][0];
      ans += a[i][0] - b[i][0];
      c[++cnt] = a[i][1] + b[i][1];
      ans += a[i][1] - b[i][1];
    } else {
      if (a[i][0] > b[i][1]) {
        c[++cnt] = 0;
        ans += 2 * (a[i][0] - b[i][1]);
      }
      if (b[i][0] > a[i][1]) {
        c[++cnt] = 0;
        ans -= 2 * (b[i][0] - a[i][1]);
      }
    }
  }
  sort(c + 1, c + 1 + cnt);
  for (i = 1; i <= cnt; i++) ans += (cnt - i & 1) ? -c[i] : c[i];
  ans /= 2;
  printf("%I64d\n", ans);
}
