Faster with sorted arrays.