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