#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, ans = 0, alisa = 0, bob = 0;
  cin >> n;
  vector<int> game(2 * n);
  for (int i = 0; i < n; ++i) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d) {
      game[2 * i] = (a + b);
      game[2 * i + 1] = (c + d);
      alisa += a + c;
      bob += b + d;
    } else {
      if (a > d) ans += 2 * (a - d);
      if (b > c) ans -= 2 * (b - c);
    }
  }
  ans += alisa - bob;
  sort(game.begin(), game.end());
  for (int i = n - 1; i >= 0; --i) ans += game[2 * i + 1] - game[2 * i];
  cout << ans / 2 << "\n";
  return 0;
}
