If the i - th index is still not present in its correct position , store the index
if ( arr [ i ] != i ) : NEW_LINE INDENT pos . append ( i ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE if ( arr [ i ] != i ) : NEW_LINE INDENT pos1 = i NEW_LINE pos2 = arr [ i ] NEW_LINE pos3 = arr [ arr [ i ] ] NEW_LINE DEDENT