Polycarp present sequence integer length n 1 le a_i le n a sequence Polycarp happy consist different number ie distinct numbersin order sequence like Polycarp go possibly zero number movesIn remove leftmost element sequence for example sequence 3 1 4 3 produce sequence 1 4 3 consist different numbersDetermine minimum number move need remain sequence element different in word find length small prefix give sequence remove value sequence unique