Vladik bored way home decide play follow game he take n card row every card positive integer number exceed 8 write he decide find long subsequence card satisfie follow condition number occurrence number 1 8 subsequence do not differ 1 number occurrence number Formally ck card number k subsequence pair integer condition cicj1 hold card number x subsequence card number x subsequence form continuous segment necessarily continuous segment original sequence for example subsequence 1122 satisfie condition subsequence 1221 do not note 1122 do not satisfy condition please help Vladik find length long subsequence satisfie condition