#ifdef NACHIA #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #include #include #include #include using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(i64 i=0; i void chmin(A& l, const A& r){ if(r < l) l = r; } template void chmax(A& l, const A& r){ if(l < r) l = r; } using namespace std; void testcase(){ i64 N; cin >> N; vector A(N); rep(i,N) cin >> A[i]; i64 ans = max(A.back(), 0) - min(A.front(), 0); ans *= 2; cout << ans << "\n"; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); rep(f,1) testcase(); return 0; }