#include <bits/stdc++.h>
using namespace std;
struct pila {
  long long a1, b1;
  long long a2, b2;
  long long val;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<pila> V(n);
  long long a = 0;
  long long b = 0;
  priority_queue<pair<long long, long long> > Q;
  for (long long i = 0; i < n; ++i) {
    cin >> V[i].a1 >> V[i].b1 >> V[i].a2 >> V[i].b2;
    V[i].val = 0;
    if (V[i].a1 < V[i].b2 and V[i].a2 > V[i].b1) {
      continue;
    }
    if (V[i].a1 - V[i].b2 <= V[i].a2 - V[i].b1 and V[i].a2 <= V[i].b1) {
      a += V[i].a2;
      b += V[i].b1;
    } else if (V[i].a2 - V[i].b1 >= V[i].a1 - V[i].b2 and V[i].a1 >= V[i].b2) {
      a += V[i].a1;
      b += V[i].b2;
    } else if (V[i].a1 + V[i].b1 > V[i].a2 + V[i].b2) {
      Q.push(pair<long long, long long>(V[i].a1 + V[i].b1, i));
    }
  }
  while (!Q.empty()) {
    long long i = Q.top().second;
    Q.pop();
    if (V[i].val)
      a += V[i].a2;
    else {
      V[i].val = 1;
      a += V[i].a1;
      Q.push(pair<long long, long long>(V[i].a2 + V[i].b2, i));
    }
    if (Q.empty()) break;
    i = Q.top().second;
    Q.pop();
    if (V[i].val)
      b += V[i].b2;
    else {
      V[i].val = 1;
      b += V[i].b1;
      Q.push(pair<long long, long long>(V[i].a2 + V[i].b2, i));
    }
  }
  cout << a - b << '\n';
}
