#include using namespace std; using ll = long long; using P = pair; #define rep(i,n) for(int i=0;i> n; deque a; ll x; rep(i,2*n){ cin >> x; a.push_back(x); } ll hom = 0l,tem = 0l; rep(i,n){ if (a[0]-a[1]>a[a.size()-1]-a[a.size()-2]){ hom += a[0]; a.pop_front(); tem += a[0]; a.pop_front(); } else { hom += a[a.size()-1]; a.pop_back(); tem += a[a.size()-1]; a.pop_back(); } } cout << hom - tem << endl; return 0; }