#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int n;
  long long ans = 0;
  scanf(" %d", &n);
  vector<long long> V;
  for (int i = (int)(0); i < (int)(n); ++i) {
    int a[2], b[2];
    scanf(" %d%d%d%d", a, b, a + 1, b + 1);
    if (a[0] <= b[1] && b[0] <= a[1]) continue;
    ans += a[0] + a[1];
    int x = a[0] + b[0];
    int y = a[1] + b[1];
    if (x <= y) {
      if (a[0] < b[1])
        ans -= x;
      else
        ans -= y;
    } else {
      V.push_back(x);
      V.push_back(y);
    }
  }
  sort((V).begin(), (V).end(), greater<long long>());
  for (int i = 1; i < V.size(); i += 2) {
    ans -= V[i];
  }
  cout << ans << endl;
  return 0;
}
