almost correct solution ot the AbsDistinct problem