favorite We need a little bit of your help to keep things running, click on this banner to learn more

Azerbaijan Programming Olympiad - 2nd Stage preparation

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.


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


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
2 5 3 4 6 1
Output example #1
2 3 4 6