#include <bits/stdc++.h>
using namespace std;
long long ans;
int main() {
  int n;
  cin >> n;
  priority_queue<int> pq;
  while (n--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b >= c + d) {
      pq.push(a + b);
      pq.push(c + d);
      ans += a + c;
    } else {
      ans += max(a - d, 0);
      ans -= max(b - c, 0);
    }
  }
  while (!pq.empty()) {
    ans -= pq.size() % 2 * pq.top();
    pq.pop();
  }
  cout << ans << endl;
}
