Function that returns the earliest time when a frog can jump to the other side of a river