Solve 004 in Haskell.