occurrences in sorted array