#include #define int long long using namespace std; using Graph = vector>; signed main(){ int N; cin >> N; vector A(2*N); for( int i = 0; i < 2*N; i++ ) cin >> A.at(i); int homu = 0; int tenn = 0; int r = 2*N-1; int l = 0; while( l < r ){ int migi = A.at(r)-A.at(r-1); int hidari = A.at(l)-A.at(l+1); if( migi > hidari ){ homu += A.at(r); tenn += A.at(r-1); r-= 2; }else{ homu += A.at(l); tenn += A.at(l+1); l += 2; } } cout << homu-tenn << endl; }