CF2200B.Deletion Sort

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Deletion Sort

AksLolCoding is playing a game on an array aa of nn positive integers. During each turn:

  • If aa is non-decreasing^{\text{∗}}, the game ends.
  • Otherwise, AksLolCoding can choose any single element and remove it from the array.

Determine the minimum possible number of elements that can be remaining in the array after the game ends.

^{\text{∗}}aa is non-decreasing if aiai+1a_i\leq a_{i+1} for all 1im11\leq i\leq m-1, where mm is the length of aa.

Input

The first line contains an integer tt (1t10001 \leq t \leq 1000), the number of test cases.

The first line of each test case contains an integer nn (1n101 \leq n \leq 10).

The second line of each test case contains nn integers, the elements of aa (1ai1001 \leq a_i \leq 100).

Output

For each test case, output an integer: the minimum possible number of elements left once the array is sorted.

Note

In the first test case, the minimum of 11 element can be achieved by removing 11, 22, and 33 in that order.

In the second and third test cases, no elements can be removed.

Samples

3
4
1 4 2 3
1
100
2
6 7
1
1
2

在线编程 IDE

建议全屏模式获得最佳体验