search sorted array with unknown length