Number of unique elements in sorted array with repeated elements