Haskell Array Change
arrayChange :: [Int] -> Int
arrayChange []       = 0
arrayChange (x : xs) = snd (foldl step (x, 0) xs)
  where
    step (prev, total) cur
      | prev >= cur = (prev + 1, total + (prev - cur + 1))
      | otherwise   = (cur, total)

This moves left to right and bumps values only when needed so the array becomes strictly increasing.