Completed longestSortedSequence