#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
long long ans;
int cnt, n, a1, a2;
int q[N], b1, b2;
inline int read() {
  int a = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) a = (a << 3) + (a << 1) + ch - '0';
  return a * f;
}
signed main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a1 = read();
    b1 = read();
    a2 = read();
    b2 = read();
    if (a1 + b1 >= a2 + b2) {
      q[++cnt] = a1 + b1;
      q[++cnt] = a2 + b2;
      ans += a1 + a2;
    } else if (a1 > b2)
      ans += a1 - b2;
    else if (b1 > a2)
      ans += a2 - b1;
  }
  sort(q + 1, q + cnt + 1);
  for (int i = 1; i <= cnt; i += 2) ans -= q[i];
  printf("%lld\n", ans);
  return 0;
}
