#include <bits/stdc++.h>
using namespace std;
const long long UNDEF = -1;
const long long INF = 1e18;
template <typename T>
inline bool chkmax(T& aa, T bb) {
  return aa < bb ? aa = bb, true : false;
}
template <typename T>
inline bool chkmin(T& aa, T bb) {
  return aa > bb ? aa = bb, true : false;
}
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
const long long mn = 1e5 + 4;
long long a1[mn], b1[mn], a2[mn], b2[mn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld%lld%lld%lld", a1 + i, b1 + i, a2 + i, b2 + i);
  }
  long long a = 0, b = 0;
  priority_queue<pair<long long, long long> > pq;
  for (long long i = 1; i <= n; i++) {
    if (a1[i] + b1[i] <= a2[i] + b2[i]) {
      if (a1[i] > b2[i]) {
        a += a1[i];
        b += b2[i];
      }
      if (b1[i] > a2[i]) {
        b += b1[i];
        a += a2[i];
      }
    } else {
      pq.push(make_pair(a1[i] + b1[i], i));
    }
  }
  long long turn = 0;
  while (!pq.empty()) {
    pair<long long, long long> top = pq.top();
    pq.pop();
    long long i = top.second;
    if (i > 0) pq.push(make_pair(a2[i] + b2[i], -i));
    long long l, r;
    if (i > 0)
      l = a1[i], r = b1[i];
    else
      l = a2[abs(i)], r = b2[abs(i)];
    if (turn)
      b += r;
    else
      a += l;
    turn ^= 1;
  }
  printf("%lld\n", a - b);
}
