almostsortedinterval new algorithm