#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k = 1, score = 0;
  cin >> n;
  priority_queue<pair<long long, long long> > good;
  for (int i = (0); i < (int)(n); ++i) {
    long long a1, b1, a2, b2;
    cin >> a1 >> b1 >> a2 >> b2;
    long long x = a1 + b1, y = a2 + b2, t = a1 + a2 - b1 - b2;
    if (x > y)
      good.push({x, -y}), score += t;
    else if (+t > y - x)
      score += 2 * (a1 - b2);
    else if (-t > y - x)
      score += 2 * (a2 - b1);
  }
  while (!good.empty()) {
    long long a = good.top().first, b = good.top().second;
    good.pop();
    score += a * k;
    if (b != 1) good.push({-b, 1});
    k = -k;
  }
  cout << score / 2 << endl;
  return 0;
}
