Push the index in the indices [ A [ i ] ] and also store the numbers in set to get the numbers present in input array
for i in range ( N ) : NEW_LINE INDENT indices [ arr [ i ] ] . append ( i ) NEW_LINE elements . append ( arr [ i ] ) NEW_LINE DEDENT elements = list ( set ( elements ) ) NEW_LINE