#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const int MN = 1e5 + 10;
int n, a[MN << 1], b[MN << 1];
struct cmp {
  bool operator()(const int &x, const int &y) {
    if (a[x] + b[x] != a[y] + b[y]) return a[x] + b[x] > a[y] + b[y];
    return x > y;
  }
};
set<int, cmp> S;
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[2 * i] >> b[2 * i] >> a[2 * i + 1] >> b[2 * i + 1];
    int x = a[2 * i] + b[2 * i], y = a[2 * i + 1] + b[2 * i + 1];
    if (a[2 * i] > b[2 * i + 1] || b[2 * i] > a[2 * i + 1]) {
      if (x >= y)
        S.insert(2 * i), S.insert(2 * i + 1);
      else {
        if (a[2 * i] > b[2 * i + 1])
          ans += a[2 * i] - b[2 * i + 1];
        else
          ans += a[2 * i + 1] - b[2 * i];
      }
    }
  }
  bool turn = false;
  while (!S.empty()) {
    int x = *S.begin();
    S.erase(S.begin());
    if (!turn)
      ans += a[x];
    else
      ans -= b[x];
    turn = !turn;
  }
  cout << ans << '\n';
  return 0;
}
