#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, i, n;
long long answer;
vector<pair<int, int> > photos;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    if (a + b >= c + d) {
      photos.push_back(make_pair(a, b));
      photos.push_back(make_pair(c, d));
    } else {
      if (a > d) photos.push_back(make_pair(a - d, d - a));
      if (b > c) photos.push_back(make_pair(c - b, b - c));
    }
  }
  for (i = 0; i < photos.size(); ++i) {
    answer += photos[i].first - photos[i].second;
    photos[i] = make_pair(photos[i].first + photos[i].second,
                          photos[i].first + photos[i].second);
  }
  sort(photos.begin(), photos.end(),
       [&](pair<int, int> x, pair<int, int> y) { return x > y; });
  for (int i = 0; i < photos.size(); ++i)
    if (i % 2)
      answer -= photos[i].first;
    else
      answer += photos[i].first;
  printf("%I64d\n", answer / 2);
  return 0;
}
