Pak Chanek n blank heartshape card Card 1 attach directly wall card hang exactly card piece string specifically card 1 hang card p_i p_i iIn begin Pak Chanek write integer number card he choose permutation 1 2 dot n then number write card a_iafter Pak Chanek follow operation n time maintain sequence s initially Choose card x card hang Append number write card x end s if x neq 1 number card p_x large number card x replace number card p_x number card x Remove card x after Pak Chanek sequence s n element what maximum length long nondecrease subsequencedagger s end Pak chanek step optimallydagger a sequence b subsequence sequence c b obtain c deletion possibly zero element for example 31 subsequence 321 431 31 1337 3104