fork download
  1. import Control.Monad
  2. import Control.Monad.Instances
  3.  
  4. main = readLn >>= print . sum . (liftM2 (zipWith min) (scanl1 max) (scanr1 max) >>= zipWith (-))
Success #stdin #stdout 0s 6304KB
stdin
[0, 5, 0, 1, 6000, 0, 2, 1, 0]
stdout
11