#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int oo = 0x3f3f3f3f;
const int maxn = 200100;
int n;
int a[maxn + 5][2];
bool bbig[maxn + 5];
bool take[maxn + 5][2];
int delta[maxn + 5][2];
int pos[maxn + 5];
bool vis[maxn + 5];
long long income[2];
inline void pick(bool player, int id) {
  income[player] += a[id][player];
  vis[id] = 1;
}
int main() {
  scanf("%d", &n);
  for (int i = (0), i_end_ = (n); i < i_end_; ++i)
    scanf("%d%d%d%d", a[i], a[i] + 1, a[n + i], a[n + i] + 1);
  for (int i = (0), i_end_ = (n); i < i_end_; ++i) {
    delta[i][0] = a[i][0] - a[n + i][1];
    delta[i][1] = a[i][1] - a[n + i][0];
    if (a[n + i][0] + a[n + i][1] >= a[i][0] + a[i][1]) bbig[i] = 1;
    for (int j = (0), j_end_ = (2); j < j_end_; ++j)
      take[i][j] = !(delta[i][j] <= 0 && -delta[i][!j] >= delta[i][j]);
  }
  for (int i = (0), i_end_ = (n << 1); i < i_end_; ++i) pos[i] = i;
  sort(pos, pos + (n << 1), [&](int first, int second) {
    return a[first][0] + a[first][1] > a[second][0] + a[second][1];
  });
  int p[2] = {0, 0};
  for (int i = (0), i_end_ = (n << 1); i < i_end_; ++i) {
    bool now = i & 1;
    while (p[now] < (n << 1)) {
      int first = pos[p[now]];
      if (!vis[first]) {
        if (first >= n) {
          if (vis[first - n]) {
            pick(now, first);
            break;
          }
        } else if (take[first][now]) {
          pick(now, first);
          if (bbig[first])
            pick(!now, first + n);
          else
            break;
        }
      }
      ++p[now];
    }
  }
  printf("%I64d\n", income[0] - income[1]);
  return 0;
}
