#include <bits/stdc++.h>
using namespace std;
const long long INF = 1 << 28;
const long long LINF = 1ll << 61;
inline long long getnum() {
  register long long r = 0;
  register bool ng = 0;
  register char c;
  c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') ng = 1, c = getchar();
  while (c >= '0' && c <= '9') r = r * 10 + c - '0', c = getchar();
  if (ng) r = -r;
  return r;
}
template <class T>
inline void putnum(T x) {
  if (x < 0) putchar('-'), x = -x;
  register short a[20] = {}, sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
inline void putsp() { putchar(' '); }
inline void putendl() { putchar('\n'); }
inline char mygetchar() {
  register char c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  return c;
}
long long n, Sa, Sb, a, b;
long long t[100111];
set<pair<long long, int> > s;
int main() {
  n = getnum();
  for (int i = 1; i <= n; i++) {
    long long a1, a2, b1, b2;
    a1 = getnum(), b1 = getnum();
    a2 = getnum(), b2 = getnum();
    if (a1 <= b2 && b1 <= a2) continue;
    Sa += a1;
    Sa += a2;
    Sb += b1;
    Sb += b2;
    if (a1 + b1 <= a2 + b2 && (a1 <= b2 || b1 <= a2)) {
      if (a1 <= b2) {
        b += a1 + b1;
        a += a2 + b2;
      } else if (b1 <= a2) {
        a += a1 + b1;
        b += a2 + b2;
      }
    } else {
      s.insert(make_pair(-(a1 + b1), i));
      t[i] = a2 + b2;
    }
  }
  bool flag = 1;
  while (s.size() > 0) {
    long long x = -s.begin()->first, y = s.begin()->second;
    s.erase(s.begin());
    if (flag)
      a += x;
    else
      b += x;
    if (t[y] != -1) {
      s.insert(make_pair(-t[y], y));
      t[y] = -1;
    }
    flag ^= 1;
  }
  cout << (a - b + Sa - Sb) / 2 << endl;
  return 0;
}
