eolymp
Problems

Increasing subsequence

Increasing subsequence

Given n (1n105) integers x1, x2, ..., xn (1xi60000). Delete from them the least amount of numbers so that the rest were in ascending order.

Input

First line contains the number n. In the second line the integers x1, x2, ..., xn are given.

Output

Print in the first line the amount of not erased numbers, in the second print the list of unerased numbers in the original order. If several answers exist, print any.

Time limit 1 second
Memory limit 128 MiB
Input example #1
6
2 5 3 4 6 1
Output example #1
4
2 3 4 6