### Problem Statement

You have a sequence of numbers from which you must create the longest subsequence satisfying the following condition: it can be 'cut' into two parts that share exactly one common element (the last element of the first part is the first element of the second part), and the first part is sorted in strictly ascending order while the second part is sorted in strictly descending order. For example, the sequence { 1, 4, 6, 5, 2, 1 } can be 'cut' into { 1, 4, 6 } and { 6, 5, 2, 1 }. The two parts share the 6, and the first sequence is sorted in ascending order while the second sequence is sorted in descending order.

You are given a int[] numbers, a sequence of numbers. Return the minimal number of elements you must throw out from the given sequence such that the remaining subsequence satisfies the condition described above.

### Definition

 Class: IntegerSequence Method: maxSubsequence Parameters: int[] Returns: int Method signature: int maxSubsequence(int[] numbers) (be sure your method is public)

### Constraints

-numbers will contain between 1 and 50 elements, inclusive.
-Each element of numbers will be between 1 and 1000000000, inclusive.

### Examples

0)

 `{1, 4, 6, 5, 2, 1}`
`Returns: 0`
1)

 `{1, 2, 1, 2, 3, 2, 1, 2, 1}`
`Returns: 4`
 The longest subsequence is { 1, 2, 3, 2, 1 }, so you need to throw out at least 4 elements.
2)

 `{2, 2, 2, 2, 2}`
`Returns: 4`
3)

 `{4,5,65,34,786,45678,987,543,2,6,98,580,4326,754,54,2,1,3,5,6,8,765,43,3,54}`
`Returns: 14`

#### Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=5922

#### Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=8075&pm=5922

Vedensky

#### Testers:

PabloGilberto , brett1479 , Olexiy

#### Problem categories:

Dynamic Programming