Shlok is playing a game on an array a of n positive integers. During each turn:
a is non-decreasing, the game ends.Determine the minimum possible number of elements that can remain in the array after the game ends.
An array a of length m is non-decreasing if a_i <= a_{i+1} for all 1 <= i <= m-1. A single remaining element is always trivially non-decreasing.
The first line contains a single integer t (1 <= t <= 1000) — the number of test cases.
For each test case:
The first line contains an integer n (1 <= n <= 10) — the length of the array.
The second line contains n integers a_1, a_2, ..., a_n (1 <= a_i <= 100) — the elements of the array.
For each test case, output a single integer: the minimum possible number of elements left in the array once it is non-decreasing.
1 <= t <= 1000
1 <= n <= 10
1 <= a[i] <= 100
3 4 1 4 2 3 1 100 2 6 7
1 1 2
In the first test case, the array [1, 4, 2, 3] is not sorted, so it can be reduced down to a single element. In the second test case, the array already has one element, so it stays as is. In the third test case, [6, 7] is already non-decreasing, so no elements need to be removed.
Run uses this input. Submit always judges the hidden tests.