#include <bits/stdc++.h>
using namespace std;
namespace std {
template <typename T, typename U>
struct hash<pair<T, U>> {
  hash<T> t;
  hash<U> u;
  size_t operator()(const pair<T, U>& p) const {
    return t(p.first) ^ (u(p.second) << 7);
  }
};
}  // namespace std
template <typename T, typename F>
T bsh(T l, T h, const F& f) {
  T r = -1, m;
  while (l <= h) {
    m = (l + h) / 2;
    if (f(m)) {
      l = m + 1;
      r = m;
    } else {
      h = m - 1;
    }
  }
  return r;
}
template <typename T, typename F>
T bsl(T l, T h, const F& f) {
  T r = -1, m;
  while (l <= h) {
    m = (l + h) / 2;
    if (f(m)) {
      h = m - 1;
      r = m;
    } else {
      l = m + 1;
    }
  }
  return r;
}
template <typename T>
T gcd(T a, T b) {
  if (a < b) swap(a, b);
  return b ? gcd(b, a % b) : a;
}
int main(int, char**) {
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  long long A = 0, B = 0;
  priority_queue<pair<pair<long long, long long>, int>> Q;
  vector<pair<pair<long long, long long>, pair<long long, long long>>> D;
  for (int i = 0; i < N; i++) {
    long long a1, b1, a2, b2;
    cin >> a1 >> b1 >> a2 >> b2;
    if (a1 + b1 + a2 + b2 == 0) continue;
    if (a1 + b1 > a2 + b2) {
      Q.push({{a1 + b1, a1 + b1}, D.size()});
      D.push_back({{a1, b1}, {a2, b2}});
    } else if (b1 > a2) {
      A += a2;
      B += b1;
    } else if (a1 > b2) {
      A += a1;
      B += b2;
    }
  }
  bool t = true;
  while (!Q.empty()) {
    auto q = Q.top();
    Q.pop();
    if (q.first.first == 0) break;
    if (t)
      A += D[q.second].first.first;
    else
      B += D[q.second].first.second;
    t = !t;
    D[q.second] = {D[q.second].second, {0, 0}};
    int s = D[q.second].first.first + D[q.second].first.second;
    if (s > 0) {
      Q.push({{s, s}, q.second});
    }
  }
  cout << A - B << endl;
}
