#include <bits/stdc++.h>
using namespace std;
int hl, s[100010][2], k[100010], h[100010];
void up(int i) {
  int j = i >> 1;
  while (j && s[h[i]][k[h[i]]] > s[h[j]][k[h[j]]]) {
    swap(h[i], h[j]);
    i = j;
    j >>= 1;
  }
}
void down(int i) {
  int j = i << 1;
  while (j <= hl) {
    if (j < hl && s[h[j + 1]][k[h[j + 1]]] > s[h[j]][k[h[j]]]) j++;
    if (s[h[i]][k[h[i]]] < s[h[j]][k[h[j]]]) {
      swap(h[i], h[j]);
      i = j;
      j <<= 1;
    } else
      break;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0;
  int m = 0;
  for (int i = 1; i <= n; i++) {
    int x0, y0, x1, y1;
    scanf("%d%d%d%d", &x0, &y0, &x1, &y1);
    if (x0 <= y1 && y0 <= x1) continue;
    if (x0 + y0 <= x1 + y1) {
      if (x0 > y1)
        ans += x0 - y1;
      else
        ans += x1 - y0;
      continue;
    }
    ans = ans - y0 - y1;
    s[++m][0] = x0 + y0;
    s[m][1] = x1 + y1;
  }
  for (int i = 1; i <= m; i++) {
    k[i] = 0;
    h[i] = i;
    up(i);
  }
  hl = m;
  for (int i = 1; i < 2 * m; i++) {
    int first = h[1];
    if (i & 1) ans += s[first][k[first]];
    if (++k[first] >= 2) h[1] = h[hl--];
    down(1);
  }
  printf("%I64d\n", ans);
  return 0;
}
