#include <bits/stdc++.h>
using namespace std;
int n;
long long a, b, c, d, ans = 0;
vector<long long> lastVal;
void getStack() {
  cin >> a >> b >> c >> d;
  if (a + b >= c + d) {
    ans += a - b + c - d;
    lastVal.push_back(a + b);
    lastVal.push_back(c + d);
    return;
  }
  if (a > d) {
    ans += (a - d) << 1;
    return;
  }
  if (b > c) {
    ans += (c - b) << 1;
    return;
  }
}
void setup() {
  cin >> n;
  for (int i = 1; i <= n; i++) getStack();
  sort(lastVal.begin(), lastVal.end(), greater<long long>());
  for (int i = 0; i <= int(lastVal.size()) - 1; i++)
    ans += lastVal[i] * (i & 1 ? -1 : 1);
  cout << (ans >> 1);
}
void xuly() {}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  setup();
  xuly();
  return 0;
}
