Farmer John is arranging his cows in a line to take a photo. The height of the -th cow in the lineup is a_i, and Farmer John thinks the photo would look more aesthetically pleasing if the lineup contained a long increasing subsequence of cows by height.
Recall that a subsequence is a sequence of elements a_{i_1}, a_{i_2}, \ldots, a_{i_k} from the original sequence, where the corresponding indices satisfy i_1 < i_2 < \ldots < i_k. We say that the subsequence is increasing if a_{i_1} \le a_{i_2} \le \ldots \le a_{i_k}.
FJ would like his lineup to contain a long increasing subsequence. To help achieve this, he may choose any subsequence of the cows and reverse the order of its elements.
For example, suppose the lineup is
1 6 2 3 4 3 5 3 4We can choose the elements marked below:
1 6 2 3 4 3 5 3 4
^ ^ ^ ^and reverse their order to obtain
1 4 2 3 4 3 3 5 6
^ ^ ^ ^Notice that the reversed elements occupy exactly the same set of positions as before, while all other elements remain unchanged.
Determine the maximum possible length of an increasing subsequence after reversing the elements of at most one subsequence.
The first line contains n~(1 \le n \le 50). The next lines contain a_1, \ldots, a_n, where each a_i is an integer in the range .
Print the maximum possible length of an increasing subsequence after reversing the elements of at most one subsequence.
Example 1