1707 - Sorting

Time Limit : 1 Second

Memory Limit : 128 MB

Submission: 41

Solved: 2

Description

Sorting is easy. An easy way to sort an array is that in every step we take an element out of the array and places it either at the beginning or the end of the array. In this way, what is the minimum step to sort an array in non-decreasing order?

Input

The first line of the input contains an integer T (T=60), denoting the number of test cases.
In each test case, the first line of the input contains N — the number of elements in A (1 ≤ N ≤ 3 * 104). The second line contains N integer numbers Ai (1 ≤ Ai ≤ 105).

Output

For each case, output the minimum step needed to sort the array.

sample input
2
5
2 5 1 3 3
4
1 2 2 1
sample output
2
1
hint
source
yangyue
© 2015 HUST ACMICPC TEAM. All Right Reserved.