you give permutation p_1 p_2 ldot p_nIn swap adjacent valuesyou want perform minimum number move end exist subsegment 12ldots k word end integer 1 leq leq nk1 p_i 1 p_i1 2 ldot p_ik1klet fk minimum number move need subsegment value 12ldotsk appear permutationyou need find f1 f2 ldot fn