#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
inline void priv(vector<int> a) {
  for (int i = 0; i < ((int)(a).size()); ++i)
    printf("%d%c", a[i], i == (int)(a).size() - 1 ? '\n' : ' ');
}
template <typename T>
istream& operator>>(istream& i, vector<T>& v) {
  for (int j = 0; j < ((int)(v).size()); ++j) i >> v[j];
  return i;
}
template <typename T>
string join(vector<T>& v) {
  stringstream s;
  for (int i = 0; i < ((int)(v).size()); ++i) s << ' ' << v[i];
  return s.str().substr(1);
}
template <typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
  if ((int)(v).size()) o << join(v);
  return o;
}
template <typename T1, typename T2>
istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, pair<T1, T2>& v) {
  return o << v.first << "," << v.second;
}
const int MX = 100005, INF = 1001001001;
const long long int LINF = 1e18;
const double eps = 1e-10;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> x;
  long long int sum = 0;
  for (int i = 0; i < (n); ++i) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (a <= d && b <= c) continue;
    long long int s = a + b, t = c + d;
    if (s <= t) {
      if (a <= d)
        sum += c - b;
      else
        sum += a - d;
    } else {
      sum += a + c;
      x.push_back(s);
      x.push_back(t);
    }
  }
  sort(x.begin(), x.end());
  reverse(x.begin(), x.end());
  for (int i = 0; i < ((int)(x).size()); ++i) {
    if (i & 1) sum -= x[i];
  }
  cout << sum << endl;
  return 0;
}
