#include <bits/stdc++.h>
using namespace std;
int n;
int a1[100010], b1[100010], a2[100010], b2[100010];
priority_queue<int> pq;
long long ans;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a1[i] >> b1[i] >> a2[i] >> b2[i];
    int x = a1[i] + b1[i];
    int y = a2[i] + b2[i];
    int z = a1[i] + a2[i] - b1[i] - b2[i];
    if (x >= y) {
      pq.push(x);
      pq.push(y);
      ans += z;
    } else if (z > 0 && a1[i] > b2[i]) {
      ans += 2 * (a1[i] - b2[i]);
    } else if (z < 0 && b1[i] > a2[i]) {
      ans += 2 * (a2[i] - b1[i]);
    }
  }
  for (int t = 1; !pq.empty(); t *= -1) {
    int x = pq.top();
    pq.pop();
    ans += t * x;
  }
  cout << ans / 2 << '\n';
}
