Count occurences of a num in sorted array