#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
const int MAXN = 400001;
int b[MAXN];
int bc = 0;
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int a1, b1, a2, b2;
    cin >> a1 >> b1 >> a2 >> b2;
    if ((a1 <= b2) && (b1 <= a2)) continue;
    if (a1 + b1 <= a2 + b2) {
      if (a1 > b2)
        ans += (a1 - b2);
      else
        ans += (a2 - b1);
      continue;
    }
    ans -= (b1 + b2);
    b[bc++] = (a1 + b1);
    b[bc++] = (a2 + b2);
  }
  sort(b, b + bc);
  for (int i = 1; i < bc; i += 2) {
    ans += b[i];
  }
  cout << ans << endl;
  return 0;
}
