f xs = sum $ zipWith (-) (zipWith min (scanl1 max xs) (scanr1 max xs)) xsmain = readLn >>= (print . f)
[0, 5, 0, 1, 6000, 0, 2, 1, 0]
11
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!