Remove duplicates from sorted array 2

More extensible version.