#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b >= c + d) {
      v.emplace_back(a + b, a - b);
      v.emplace_back(c + d, c - d);
    } else {
      if (a > d)
        v.emplace_back(0, 2 * (a - d));
      else if (b > c)
        v.emplace_back(0, 2 * (c - b));
    }
  }
  if (v.size() == 0) {
    cout << 0;
    return 0;
  }
  sort(v.begin(), v.end(), greater<pair<int, int> >());
  long long res = 0;
  for (int i = 0; i <= v.size() - 1; i++) {
    res += v[i].second;
    if ((i % 2) == 0)
      res += v[i].first;
    else
      res -= v[i].first;
  }
  res /= 2;
  cout << res;
}
