#include <bits/stdc++.h>
using namespace std;
inline void print(char pt) { printf("%c\n", pt); }
inline void print(int pt) { printf("%d\n", pt); }
inline void print(long long pt) { printf("%I64d\n", pt); }
inline void print(double pt) { printf("%.20f\n", pt); }
inline void print(char pt[]) { printf("%s\n", pt); }
inline void print() { printf("\n"); }
inline int scan(int &pt) { return scanf("%d", &pt); }
inline int scan(char &pt) { return scanf("%c", &pt); }
inline int scan(long long &pt) { return scanf("%I64d", &pt); }
inline int scan(double &pt) { return scanf("%lf", &pt); }
inline int scan(char pt[]) { return scanf("%s", pt); }
struct pii {
  int a, b;
};
struct p4i {
  pii a, b;
};
int c, n;
p4i a[100008];
int b[200008];
int main() {
  long long ansb = 0;
  long long ansa = 0;
  scan(n);
  for (int i = 0; i < n; i++) {
    scan(a[i].a.a);
    scan(a[i].a.b);
    scan(a[i].b.a);
    scan(a[i].b.b);
    if (a[i].a.a + a[i].a.b < a[i].b.a + a[i].b.b) {
      if (a[i].a.a > a[i].b.b) {
        ansb += a[i].a.a - a[i].b.b;
      }
      if (a[i].a.b > a[i].b.a) {
        ansb += a[i].b.a - a[i].a.b;
      }
      i--;
      n--;
      continue;
    }
    b[i * 2] = a[i].a.a + a[i].a.b;
    ansa += a[i].a.a - a[i].a.b;
    b[i * 2 + 1] = a[i].b.a + a[i].b.b;
    ansa += a[i].b.a - a[i].b.b;
  }
  sort(b, b + n * 2, [](const int &a, const int &b) { return a > b; });
  for (int i = 0; i < n; i++) {
    ansa += b[i * 2];
    ansa -= b[i * 2 + 1];
  }
  ansa /= 2;
  print(ansa + ansb);
  return 0;
}
