Why must the input array must be sorted in ascending order?