#include <bits/stdc++.h>
using namespace std;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const int mxN = 2e5;
int q = 1, n;
long long arr[mxN][4], ans;
vector<long long> v;
void solve() {
  cin >> n;
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (4); j++) cin >> arr[i][j];
  for (int i = (0); i < (n); i++) {
    if (arr[i][0] + arr[i][1] >= arr[i][2] + arr[i][3]) {
      ans += arr[i][0] - arr[i][1] + arr[i][2] - arr[i][3];
      v.push_back(arr[i][0] + arr[i][1]);
      v.push_back(arr[i][2] + arr[i][3]);
    } else if (arr[i][0] > arr[i][3]) {
      ans += 2 * (arr[i][0] - arr[i][3]);
    } else if (arr[i][1] > arr[i][2]) {
      ans -= 2 * (arr[i][1] - arr[i][2]);
    }
  }
  sort(begin(v), end(v), greater<long long>());
  for (int i = (0); i < (v.size()); i++)
    if (i % 2 == 0)
      ans += v[i];
    else
      ans -= v[i];
  cout << ans / 2 << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  while (q--) {
    solve();
  }
}
