#include <bits/stdc++.h>
using namespace std;
int A[100005], B[100005];
int main() {
  int n;
  scanf("%d", &n);
  long long int ret = 0;
  int sz = 0;
  priority_queue<pair<int, int> > que;
  for (int i = 0; i < n; i++) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if (a <= d && b <= c) continue;
    if (a + b <= c + d) {
      if (a >= d)
        ret += a - d;
      else
        ret -= b - c;
      continue;
    }
    ret += a + c;
    A[sz] = a + b, B[sz] = c + d;
    que.push(pair<int, int>(A[sz], sz));
    sz++;
  }
  int turn = 0;
  while (!que.empty()) {
    pair<int, int> p = que.top();
    que.pop();
    if (turn == 1) ret -= p.first;
    int v = p.second;
    if (A[v] == p.first) que.push(pair<int, int>(B[v], v));
    turn ^= 1;
  }
  printf("%lld\n", ret);
  return 0;
}
