you give permutation p_1 p_2 ldot p_nimagine position permutation contain bomb exist position bombfor fix configuration bomb consider follow process initially set AFor 1 n add p_i a if ith position contain bomb remove large element aafter process complete a nonempty the cost configuration bomb equal large element AYou give permutation q_1 q_2 ldot q_nFor 1 leq leq n find cost configuration bomb exist bomb position q_1 q_2 ldot q_i1 for example i1 need find cost configuration bomb need find cost configuration bomb position q_1 q_2 ldot q_n1