# Haskell, <s>82</s> 81 bytes This is a port of [my Clean answer](https://codegolf.stackexchange.com/a/165066/42682). r!n=foldr(f n)[[last r]]$init r f n x(r@(a:_):s)|x>a=[x,n+a]:(x-n:r):s|y<-x:r=y:s [Try it online!](https://tio.run/##HYhPC8IgHIbvfYp3sIOSg62iQjK6Bt06Dgmhxkb2W6iRg313k07Pn97458PalFxBqhvt3bEOxNvWGh/gtC4HGrIs8kVk7sSMvHHp@RyPRrVR0NJoyWJF0uU9T4cqSqcm6dPLDASF9ydcg7sQSvh@/Ga0jcBKYCOwFdgL1P/cCaw1CrCmhpQ4U@DpBw "Haskell – Try It Online") -1 thanks to [Laikoni](https://codegolf.stackexchange.com/users/56433/laikoni)