#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int i, j, k, n, m, a1, b1, a2, b2, ch;
long long ans;
struct cc {
  int a, b;
} A[N << 1];
void R(int &x) {
  x = 0;
  ch = getchar();
  while (ch < '0' || '9' < ch) ch = getchar();
  while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
void W(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) W(x / 10);
  putchar(x % 10 + '0');
}
bool cmp(const cc &a, const cc &b) { return a.a + a.b > b.a + b.b; }
int main() {
  R(n);
  for (i = 1; i <= n; i++) {
    R(a1);
    R(b1);
    R(a2);
    R(b2);
    if (a1 + b1 > a2 + b2) {
      A[++m].a = a1;
      A[m].b = b1;
      A[++m].a = a2;
      A[m].b = b2;
    } else {
      if (a1 > b2) ans += a1 - b2;
      if (b1 > a2) ans -= b1 - a2;
    }
  }
  sort(A + 1, A + m + 1, cmp);
  for (i = 1; i <= m; i++) {
    if (i & 1)
      ans += A[i].a;
    else
      ans -= A[i].b;
  }
  W(ans);
  puts("");
}
