#include <bits/stdc++.h>
using namespace std;
long long n;
struct nd {
  long long val;
  bool is_next;
  long long nxt;
};
bool operator<(nd a, nd b) { return a.val < b.val; }
priority_queue<nd> hh;
int main() {
  cin.sync_with_stdio(false);
  cin >> n;
  long long sub = 0;
  long long add = 0;
  for (int i = 0; i < n; i++) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a <= d && b <= c) {
      continue;
    }
    if (a + b > c + d) {
      sub += b + d;
      nd u;
      u.is_next = true;
      u.nxt = c + d;
      u.val = a + b;
      hh.push(u);
    } else {
      if (a > d) {
        add += a + b;
        sub += b + d;
      } else {
        add += c + d;
        sub += b + d;
      }
    }
  }
  bool is_my = true;
  while (!hh.empty()) {
    nd b = hh.top();
    hh.pop();
    if (is_my) {
      add += b.val;
    }
    is_my = !is_my;
    if (b.is_next) {
      b.is_next = false;
      b.val = b.nxt;
      hh.push(b);
    }
  }
  cout << add - sub << endl;
}
