#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
long long res;
int n, cnt;
int arr[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (a + b >= c + d) {
      arr[++cnt] = a + b;
      arr[++cnt] = c + d;
      res -= b + d;
    } else if (a > d)
      res += a - d;
    else if (b > c)
      res -= b - c;
  }
  sort(arr + 1, arr + cnt + 1);
  reverse(arr + 1, arr + cnt + 1);
  for (int i = 1; i <= cnt; i++)
    if (i & 1) res += arr[i];
  printf("%I64d\n", res);
  return 0;
}
