removing duplicated elements in array a[] in-place