array delete duplicates2 keeping loop invariant all the time