Solve #41 in Haskell.