#include <bits/stdc++.h>
using namespace std;
struct PicStack {
  long long a1, b1, a2, b2;
  bool topTaken;
};
vector<PicStack> vp(100000 + 10);
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  long long n;
  cin >> n;
  long long sumA = 0;
  long long sumB = 0;
  priority_queue<pair<long long, long long> > que;
  for (long long i = 0; i < (n); ++i) {
    cin >> vp[i].a1;
    cin >> vp[i].b1;
    cin >> vp[i].a2;
    cin >> vp[i].b2;
    vp[i].topTaken = false;
    long long A = vp[i].a1 - vp[i].b2;
    long long B = vp[i].a2 - vp[i].b1;
    if (B >= 0 && 0 >= A) continue;
    if (A <= B && B <= 0) {
      sumB += vp[i].b1;
      sumA += vp[i].a2;
    } else if (B >= A && A >= 0) {
      sumA += vp[i].a1;
      sumB += vp[i].b2;
    } else if (A > B) {
      que.push(make_pair(vp[i].a1 + vp[i].b1, i));
    }
  }
  bool isAturn = true;
  while (!que.empty()) {
    long long id = que.top().second;
    que.pop();
    if (isAturn) {
      if (!vp[id].topTaken) {
        sumA += vp[id].a1;
        vp[id].topTaken = true;
        que.push(make_pair(vp[id].a2 + vp[id].b2, id));
      } else {
        sumA += vp[id].a2;
      }
    } else {
      if (!vp[id].topTaken) {
        sumB += vp[id].b1;
        vp[id].topTaken = true;
        que.push(make_pair(vp[id].a2 + vp[id].b2, id));
      } else {
        sumB += vp[id].b2;
      }
    }
    isAturn = !isAturn;
  }
  cout << sumA - sumB;
  return 0;
}
