#C3313. Longest Increasing Power of 2 Subsequence

    ID: 46727 Type: Default 1000ms 256MiB

Longest Increasing Power of 2 Subsequence

Longest Increasing Power of 2 Subsequence

Given an array of integers, determine the length of the longest subsequence where every element is a power of 2 and the elements form a strictly increasing sequence. An integer \(x\) is a power of 2 if it can be represented as \(2^k\) for some non-negative integer \(k\). The subsequence must follow the original order of the array. For example, in the array [3, 10, 4, 8, 16, 20], the longest such subsequence is [4, 8, 16] with a length of 3.

inputFormat

The input is read from standard input (stdin). The first line contains a single integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers.

outputFormat

Output a single integer to standard output (stdout), denoting the length of the longest subsequence of numbers that are powers of 2 and are in strictly increasing order.

## sample
6
3 10 4 8 16 20
3

</p>