#include <bits/stdc++.h>
using namespace std;
void Read(int &n) {
  int sign = 1;
  n = 0;
  char c;
  do {
    c = getchar();
  } while (!isdigit(c) && c != '-');
  if (c == '-') {
    c = getchar();
    sign = -1;
  }
  do {
    n = n * 10 + c - 48;
    c = getchar();
  } while (isdigit(c));
  n *= sign;
}
void Read(long long &n) {
  int sign = 1;
  n = 0;
  char c;
  do {
    c = getchar();
  } while (!isdigit(c) && c != '-');
  if (c == '-') {
    c = getchar();
    sign = -1;
  }
  do {
    n = n * 10ll + c - 48;
    c = getchar();
  } while (isdigit(c));
  n *= sign;
}
void Write(int n) {
  if (n == 0) {
    putchar('0');
    return;
  } else if (n < 0)
    putchar('-'), n = -n;
  char C[30];
  int d = 0;
  while (n) {
    C[++d] = (n % 10) + 48;
    n /= 10;
  }
  for (int i = d; i >= 1; --i) putchar(C[i]);
}
void Write(long long n) {
  if (n == 0) {
    putchar('0');
    return;
  } else if (n < 0)
    putchar('-'), n = -n;
  char C[30];
  int d = 0;
  while (n) {
    C[++d] = (n % 10ll) + 48;
    n /= 10ll;
  }
  for (int i = d; i >= 1; --i) putchar(C[i]);
}
const int maxn = 1e5 + 10;
struct Pair {
  int first, second;
  Pair() {}
  Pair(int first, int second) : first(first), second(second) {}
  bool operator<(const Pair &that) const {
    return first + second < that.first + that.second;
  }
};
vector<Pair> Greed;
long long ans = 0;
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (a <= d && c >= b) continue;
    if (a + b >= c + d) {
      Greed.push_back(Pair(a, b));
      Greed.push_back(Pair(c, d));
    } else if (a <= d)
      ans += c - b;
    else if (b <= c)
      ans += a - d;
  }
  sort(Greed.begin(), Greed.end());
  reverse(Greed.begin(), Greed.end());
  for (int i = 0; i < Greed.size(); ++i) {
    if (i & 1)
      ans -= Greed[i].second;
    else
      ans += Greed[i].first;
  }
  printf("%I64d", ans);
  return 0;
}
