#include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
struct dish{
  ll A,B;
  bool operator<(const dish &o) const {return A+B < o.A+o.B;}
  bool operator>(const dish &o) const {return A+B > o.A+o.B;}
};
int main(){
  ll N,i,ans = 0;scanf("%lld",&N);
  dish D[N];
  for(i=0;i<N;i++) scanf("%lld%lld",&D[i].A,&D[i].B);
  sort(D,D+N,greater<dish>());
  for(i=0;i<N;i++){
    if(i&1) ans -= D[i].B;
    else ans += D[i].A;
  }
  printf("%lld\n",ans);
}
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
    int n;
    cin >> n;

    vi A(n), B(n), C(n);
    rep(i,n) cin >> A[i];
    rep(i,n) cin >> B[i];
    rep(i,n) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    ll ans = 0;
    rep(i,n){
        ll x = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        ll y = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        ans += x * y;
        //cout << ans << endl;
    }

    cout << ans << endl;
    return 0;
}
