#include #include #include #include #include #include #include #include #include #include using namespace std; struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<ostream &operator<<(ostream &o,const vector&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<> n; vector a(2*n); for (int64 i=0; i<2*n; i++) cin >> a[i]; int64 ans1 = a[0] - a[1]; int64 l = 2; int64 r = 2*n - 1; while(l < r) { if (a[l]-a[l+1] > a[r]-a[r-1]) { ans1 += a[l] - a[l+1]; l+=2; } else { ans1 += a[r] - a[r-1]; r-=2; } } int64 ans2 = a[2*n-1] - a[2*n-2]; l = 0; r = 2*n - 3; while(l < r) { if (a[l]-a[l+1] > a[r]-a[r-1]) { ans2 += a[l] - a[l+1]; l+=2; } else { ans2 += a[r] - a[r-1]; r-=2; } } debug(ans1); debug(ans2); cout << max(ans1,ans2) << endl; }