Rewrite list using first/last sentinels which eliminates corner cases
and facilitates the coding of the ds.