#include <bits/stdc++.h>
using namespace std;
const int maxn = 500010, inf = 1e9;
int n, a, b, c, d, cnt;
int w[maxn];
long long ans;
inline void read(int &k) {
  int f = 1;
  k = 0;
  char c = getchar();
  while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
  while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
  k *= f;
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    read(a);
    read(b);
    read(c);
    read(d);
    if (a + b >= c + d)
      ans += a - b + c - d, w[++cnt] = a + b, w[++cnt] = c + d;
    else {
      if (a > d)
        ans += (a - d) << 1;
      else if (b > c)
        ans -= (b - c) << 1;
    }
  }
  sort(w + 1, w + 1 + cnt, greater<int>());
  for (int i = 1; i <= cnt; i += 2) ans += w[i] - w[i + 1];
  printf("%I64d\n", ans >> 1);
}
