#include <bits/stdc++.h>
using namespace std;
class Grid {
 private:
  int m_a[2];
  int m_b[2];
  int m_idx;

 public:
  int Calc();
  void Get();
  int GetSum() const;
  int GetVal(bool isFirst);
  bool operator<(const Grid&) const;
  bool IsBad();
  bool IsFirst();
};
int Grid::Calc() {
  if (m_a[0] > m_b[1]) return m_a[0] - m_b[1];
  return m_a[1] - m_b[0] < 0 ? m_a[1] - m_b[0] : 0;
}
void Grid::Get() {
  for (int i = 0; i < 2; ++i) scanf("%d%d", m_a + i, m_b + i);
  m_idx = 0;
}
int Grid::GetSum() const { return m_a[m_idx] + m_b[m_idx]; }
bool Grid::operator<(const Grid& grid) const {
  return GetSum() < grid.GetSum();
}
bool Grid::IsBad() { return m_a[1] + m_b[1] > m_a[0] + m_b[0]; }
int Grid::GetVal(bool isFirst) { return isFirst ? m_a[m_idx] : -m_b[m_idx]; }
bool Grid::IsFirst() { return ++m_idx < 2; }
int main() {
  int n;
  priority_queue<Grid> q;
  scanf("%d", &n);
  auto grid = new Grid[n];
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    grid[i].Get();
    if (!grid[i].IsBad()) {
      q.push(grid[i]);
    } else
      res += grid[i].Calc();
  }
  bool isFirst = true;
  while (!q.empty()) {
    auto top = q.top();
    q.pop();
    res += top.GetVal(isFirst);
    isFirst = !isFirst;
    if (top.IsFirst()) {
      q.push(top);
    }
  }
  cout << res << endl;
  return 0;
}
