#include #include #include #include #include #include #include #include #include using namespace std; #define N (1000000000+7) #define INF 1e16 typedef long long ll; typedef pair P; int main(void){ ll ans = 0; ll n; cin>>n; vectora(2*n); for(ll i=0;i<2*n;i++)cin>>a[i]; ll left = 0,right=2*n-1; while(right>left){ ll tmp1 = a[left]-a[left+1]; ll tmp2 = a[right]-a[right-1]; if(tmp1>=tmp2){ ans+=tmp1; left+=2; } else{ ans+=tmp2; right-=2; } } cout<