#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
long long ans = 0;
int w[N << 1], l = 0;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) {
    int a1, b1, a2, b2;
    cin >> a1 >> b1 >> a2 >> b2;
    if (a1 <= b2 && b1 <= a2)
      continue;
    else {
      int s1 = a1 + b1, s2 = a2 + b2;
      if (s1 <= s2) {
        if (a1 > b2)
          ans += a1 - b2;
        else
          ans += a2 - b1;
      } else
        w[++l] = -s1, w[++l] = -s2, ans += a1 + a2;
    }
  }
  sort(w + 1, w + l + 1);
  for (int i = (1); i <= (l); i++)
    if (i % 2 == 0) ans += w[i];
  cout << ans << endl;
  return 0;
}
