#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
inline long long read() {
  register long long x = 0, f = 1;
  register char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void writeln(long long x) {
  write(x);
  puts("");
}
int a[200010], n, m;
long long ans = 0;
int main() {
  n = read();
  for (register int i = (1); i <= int(n); ++i) {
    int a1 = read(), b1 = read(), a2 = read(), b2 = read();
    if (a1 + b1 >= a2 + b2) {
      ans += a1 + a2;
      a[++m] = -b2 - a2;
      a[++m] = -b1 - a1;
    } else if (a1 > b2)
      ans += a1 - b2;
    else if (a2 < b1)
      ans += a2 - b1;
  }
  sort(a + 1, a + 1 + m);
  for (int i = 2; i <= m; i += 2) ans += a[i];
  writeln(ans);
  return 0;
}
