#P4310. 绝世好题

绝世好题

Description

Given a sequence aia_i of length nn, find the maximum length kk of a subsequence bib_i of aia_i such that bi&bi10b_i \& b_{i-1} \ne 0, where 2ik2 \le i \le k, and &\& denotes the bitwise AND operation.

Input Format

The input contains 2 lines. The first line contains an integer nn. The second line contains nn integers, where the ii-th integer is aia_i.

Output Format

Output one line containing a single integer, the maximum length of the subsequence bib_i.

3
1 2 3
2

Hint

For 100%100\% of the testdata, 1n1000001 \le n \le 100000, ai109a_i \le 10^9.

Translated by ChatGPT 5