#d1301. 连续子序列
连续子序列
Consecutive Subsequence
Problem Description
Given an array of length , find the longest consecutive increasing subsequence. That is, we want to find a subsequence satisfying and $a_{p_m} - a_{p_{m-1}} = a_{p_{m-1}} - a_{p_{m-2}} = \dots = a_{p_2} - a_{p_1} = 1$. Output the maximum and the answer subsequence with the smallest lexicographic order.
Input Format
The first line contains an integer .
The next line contains integers .
Output Format
The first line contains an integer , the length of the answer subsequence.
The second line contains integers, the answer subsequence.
Sample Input
7
3 3 4 7 5 6 8
Sample Output
4
3 4 5 6
Constraints
All data guarantee , .