#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<pair<long long, long long>, pair<long long, long long> > > v;
long long tota, totb;
void init() {
  tota = totb = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    long long a, b, c, d;
    scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &d);
    if (a + b > c + d) {
      tota -= b + d;
      v.emplace_back(pair<long long, long long>(a, b),
                     pair<long long, long long>(c, d));
    } else if (a + b == c + d) {
      tota -= b + d;
      tota += a + b;
      totb += c + d;
    } else {
      if (b - c >= 0 && d - a >= 0) {
        tota -= b;
        tota += c;
      } else if (c - b >= 0 && a - d >= 0) {
        tota += a;
        tota -= d;
      }
    }
  }
}
priority_queue<pair<long long, pair<long long, long long> > > pq;
void process() {
  for (int id = 0; id < (int)v.size(); id++) {
    pair<pair<long long, long long>, pair<long long, long long> > xx = v[id];
    pq.push(pair<long long, pair<long long, long long> >(
        xx.first.first + xx.first.second, pair<long long, long long>(id, 0)));
  }
  int turn = 0;
  while (!pq.empty()) {
    auto xx = pq.top();
    pq.pop();
    if (xx.second.second == 0) {
      if (turn == 0) {
        tota += xx.first;
      } else {
        totb += xx.first;
      }
      pq.push(pair<long long, pair<long long, long long> >(
          v[xx.second.first].second.first + v[xx.second.first].second.second,
          pair<long long, long long>(xx.second.first, 1)));
    } else {
      if (turn == 0) {
        tota += xx.first;
      } else {
        totb += xx.first;
      }
    }
    turn = 1 - turn;
  }
  printf("%I64d\n", tota);
}
int main() {
  init();
  process();
  return 0;
}
