#include <bits/stdc++.h>
using namespace std;
char c;
bool flag;
inline void read(int &a) {
  a = 0;
  do c = getchar();
  while (c != '-' && (c < '0' || c > '9'));
  c = c == '-' ? flag = true, getchar() : c;
  while (c <= '9' && c >= '0') a = (a << 3) + (a << 1) + c - '0', c = getchar();
  a = flag ? flag = false, -a : a;
}
inline int min(int a, int b) { return a > b ? b : a; }
inline int Min(int &a, int b) { return a > b ? a = b : a; }
inline long long Min(long long &a, long long b) { return a > b ? a = b : a; }
inline int max(int a, int b) { return a < b ? b : a; }
inline int Max(int &a, int b) { return a < b ? a = b : a; }
inline int abs(int a) { return a < 0 ? -a : a; }
struct cmp {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) {
    return a.first + a.second < b.first + b.second;
  }
};
int a1, a2, b1, b2;
priority_queue<pair<int, int>, vector<pair<int, int> >, cmp> pq;
int main() {
  int n;
  read(n);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    read(a1), read(b1), read(a2), read(b2);
    if (a1 + b1 >= a2 + b2)
      pq.push(make_pair(a1, b1)), pq.push(make_pair(a2, b2));
    else
      ans += max(a1 - b2, 0), ans -= max(b1 - a2, 0);
  }
  int sign = 0;
  while (!pq.empty()) {
    pair<int, int> first = pq.top();
    pq.pop();
    if (!sign)
      ans += first.first;
    else
      ans -= first.second;
    sign ^= 1;
  }
  cout << ans << endl;
}
