F - Final Shutdown

Languages: C, C++, Java, Python, Kotlin
Time & Memory limits: (details)

Input

Output

Sample test(s)

Input
2 3 2 1 4 6 5 9 7 3 2 1 2 5 10 9 2
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
84 58
--- Showing first 30 lines (click "Copy" to get full content) ---

Notes