#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
int n;
ll a1, a2, b1, b2, ans;
vector<ll> v;
int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%lld%lld%lld%lld", &a1, &b1, &a2, &b2);
    if (a1 + b1 < a2 + b2) {
      if (a1 > b2)
        ans += a1 - b2;
      else if (b1 > a2)
        ans += a2 - b1;
    } else {
      v.push_back(a1 + b1);
      v.push_back(a2 + b2);
      ans += a1 + a2;
    }
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i += 2) ans -= v[i];
  printf("%lld\n", ans);
  return 0;
}
