#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3fffffff;
const long long mod = 1000000007;
const int maxn = 1e5 + 100;
struct node {
  long long a1, b1, a2, b2;
  int tag;
  node(long long a = 0, long long b = 0, long long c = 0, long long d = 0)
      : a1(a), b1(b), a2(c), b2(d) {}
  bool operator<(const node &b) const { return a1 + b1 < b.a1 + b.b1; }
};
priority_queue<node> q;
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0;
  for (int i = 1; i < n + 1; i++) {
    long long a1, b1, a2, b2;
    scanf("%I64d%I64d%I64d%I64d", &a1, &b1, &a2, &b2);
    if (a1 < b2 && b1 < a2)
      continue;
    else if (a1 + b1 <= a2 + b2) {
      if (a1 >= b2)
        ans += a1 - b2;
      else
        ans += a2 - b1;
    } else {
      node t = node(a1, b1, a2, b2);
      t.tag = 1;
      q.push(t);
    }
  }
  int cnt = 0;
  while (!q.empty()) {
    node t = q.top();
    q.pop();
    cnt++;
    if (cnt & 1)
      ans += t.a1;
    else
      ans -= t.b1;
    if (t.tag == 1) {
      node t1 = node(t.a2, t.b2, 0, 0);
      t1.tag = 0;
      q.push(t1);
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
