solution for dups in sorted array