#include <bits/stdc++.h>
using namespace std;
const long long maxn = 131072;
const long long mod = 1000000000 + 7;
long long n, temp1, temp2, temp3, temp4, ans;
vector<long long> v;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> temp1 >> temp2 >> temp3 >> temp4;
    if (temp1 + temp2 >= temp3 + temp4) {
      v.push_back(temp1 + temp2);
      v.push_back(temp3 + temp4);
      ans = ans + temp1 - temp2;
      ans = ans + temp3 - temp4;
    } else {
      if (temp1 > temp4) ans += 2 * (temp1 - temp4);
      if (temp2 > temp3) ans += 2 * (temp3 - temp2);
    }
  }
  sort(v.begin(), v.end());
  for (int i = v.size() - 1; i >= 0; i--)
    if (i % 2 != v.size() % 2)
      ans += v[i];
    else
      ans -= v[i];
  cout << ans / 2;
}
