#include <bits/stdc++.h>
using namespace std;
struct MyStruct {
  long long val;
  long long under;
  long long scorev;
  long long scoreu;
  MyStruct(long long v, long long u, long long sv, long long su)
      : val(v), under(u), scorev(sv), scoreu(su) {}
  bool operator<(const MyStruct& m) const { return val < m.val; }
};
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  long long a1[n], a2[n], b1[n], b2[n];
  for (long long i = 0; i < n; ++i) cin >> a1[i] >> b1[i] >> a2[i] >> b2[i];
  long long ans = 0;
  priority_queue<MyStruct> pq;
  for (long long i = 0; i < n; ++i) {
    long long cnum = a1[i] + b1[i], dnum = a2[i] + b2[i];
    if (cnum < dnum) {
      if (a1[i] > b2[i]) {
        ans += a1[i] - b2[i];
      } else if (b1[i] > a2[i]) {
        ans -= b1[i] - a2[i];
      }
      continue;
    }
    if (cnum == dnum) {
      ans += (a1[i] - b2[i]);
      continue;
    }
    pq.push(MyStruct(cnum, dnum, a1[i], a2[i]));
  }
  bool first = true;
  while (!pq.empty()) {
    MyStruct top = pq.top();
    pq.pop();
    if (first)
      ans += top.scorev;
    else
      ans += (top.scorev - top.val);
    if (top.under != -1) pq.push(MyStruct(top.under, -1, top.scoreu, -1));
    first = !first;
  }
  cout << ans << endl;
}
