#include <bits/stdc++.h>
using namespace std;
struct cmp {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) {
    return a.first + a.second < b.first + b.second;
  }
};
priority_queue<pair<int, int>, vector<pair<int, int> >, cmp> pq;
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int a1, a2, b1, b2;
    scanf("%d%d%d%d", &a1, &b1, &a2, &b2);
    if (a1 + b1 >= a2 + b2) {
      pq.push(make_pair(a1, b1));
      pq.push(make_pair(a2, b2));
    } else {
      ans += max(a1 - b2, 0);
      ans -= max(b1 - a2, 0);
    }
  }
  int sign = 0;
  while (!pq.empty()) {
    pair<int, int> x = pq.top();
    pq.pop();
    if (sign == 0)
      ans += x.first;
    else
      ans -= x.second;
    sign ^= 1;
  }
  cout << ans << endl;
}
