#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
priority_queue<pair<long long, long long> > q;
int n, m = 0;
pair<long long, long long> a[maxn * 2 + 5];
int main() {
  scanf("%d", &n);
  long long ansa = 0, ansb = 0;
  for (int i = 1; i <= n; i++) {
    long long x1, y1, x2, y2;
    scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
    if (x1 + y1 < x2 + y2) {
      if (x1 > y2) {
        ansa += x1;
        ansb += y2;
      }
      if (y1 > x2) {
        ansa += x2;
        ansb += y1;
      }
      continue;
    }
    a[++m] = pair<long long, long long>(x1, y1);
    a[++m] = pair<long long, long long>(x2, y2);
  }
  n = m / 2;
  for (int i = 1; i <= m; i += 2)
    q.push(pair<long long, long long>(a[i].first + a[i].second, 1ll * i));
  int u = 1;
  while (!q.empty()) {
    pair<long long, long long> k = q.top();
    q.pop();
    if (u) {
      ansa += a[k.second].first;
    } else {
      ansb += a[k.second].second;
    }
    if (k.second & 1) {
      q.push(pair<long long, long long>(
          a[k.second + 1].first + a[k.second + 1].second,
          1ll * (k.second + 1)));
    }
    u = !u;
  }
  printf("%lld\n", ansa - ansb);
  return 0;
}
