#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> card;
long long ans = 0;
void addCard(long long x, long long y) {
  ans += (x - y) / 2;
  card.push_back((x + y) / 2);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    a *= 2;
    b *= 2;
    c *= 2;
    d *= 2;
    if (a + b >= c + d) {
      addCard(a, b);
      addCard(c, d);
    } else {
      if (a > d) addCard(a - d, d - a);
      if (b > c) addCard(c - b, b - c);
    }
  }
  sort(card.begin(), card.end(), greater<long long>());
  for (long long i = 0; i < card.size(); i++) {
    if (i % 2 == 0)
      ans += card[i];
    else
      ans -= card[i];
  }
  cout << ans / 2 << '\n';
}
