#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
double p[200010];
int n, cnt;
double ans;
inline void solve(int a, int b) {
  ans += (double)(a - b) / 2;
  p[++cnt] = (double)(a + b) / 2;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    long long a = read(), b = read(), c = read(), d = read();
    if (a + b >= c + d) {
      solve(a, b);
      solve(c, d);
    } else {
      if (a >= d) solve(a - d, d - a);
      if (b >= c) solve(c - b, b - c);
    }
  }
  sort(p + 1, p + cnt + 1, greater<double>());
  for (int i = 1; i <= cnt; i++) {
    if (i & 1)
      ans += p[i];
    else
      ans -= p[i];
  }
  printf("%.0f\n", ans);
}
