#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
priority_queue<int> q;
int n, a, b, c, d;
long long ans;
inline void in(int &x) {
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48;
}
int main() {
  in(n);
  int i;
  for (i = 1; i <= n; ++i) {
    in(a), in(b), in(c), in(d);
    if (a + b <= c + d) {
      if (a > d)
        ans += a - d;
      else if (b > c)
        ans -= b - c;
      else
        continue;
    } else
      q.push(a + b), q.push(c + d), ans -= b + d;
  }
  while (!q.empty()) ans += q.top(), q.pop(), q.pop();
  return printf("%lld\n", ans), 0;
}
