#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const long long N = 1e7;
double p[N], ans;
long long idx;
void f(double a, double b) {
  ans += (a - b) / 2;
  p[++idx] = (a + b) / 2;
}
signed main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b >= c + d) {
      f(a, b);
      f(c, d);
    } else {
      if (a >= d) f(a - d, d - a);
      if (b >= c) f(c - b, b - c);
    }
  }
  sort(p + 1, p + 1 + idx, greater<double>());
  for (long long i = 1; i <= idx; i++) {
    if (i & 1)
      ans += p[i];
    else
      ans -= p[i];
  }
  printf("%.0f\n", ans);
}
