#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, pair<int, int> > > q;
int main() {
  int n;
  long long ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a <= d && b <= c)
      ;
    else if (a - d >= 0 && c - b >= a - d)
      ans += a - d;
    else if (b - c >= 0 && d - a >= b - c)
      ans -= b - c;
    else
      q.push(make_pair(a + b, make_pair(a, b))),
          q.push(make_pair(c + d, make_pair(c, d)));
  }
  int k = 1;
  while (!q.empty()) {
    if (k == 1) ans += q.top().second.first;
    if (k == -1) ans -= q.top().second.second;
    q.pop();
    k = -k;
  }
  cout << ans << endl;
  return 0;
}
