XHXMMMlOPUl3Wg#['>%

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Statement

Amidst skyscrapers in the bustling metropolis of Metro Manila, the newest Noiph mall in the Philippines has just been completed! The construction manager, Penchick, ordered a state-of-the-art monument to be built with n n pillars.

The heights of the monument's pillars can be represented as an array h h of n n positive integers, where hi h_i represents the height of the i i -th pillar for all i i between 1 1 and n n .

Penchick wants the heights of the pillars to be in non-decreasing order, i.e. hihi+1 h_i \le h_{i + 1} for all i i between 1 1 and n1 n - 1 . However, due to confusion, the monument was built such that the heights of the pillars are in non-increasing order instead, i.e. hihi+1 h_i \ge h_{i + 1} for all i i between 1 1 and n1 n - 1 .

Luckily, Penchick can modify the monument and do the following operation on the pillars as many times as necessary:

  • Modify the height of a pillar to any positive integer. Formally, choose an index 1in 1\le i\le n and a positive integer x x . Then, assign hi:=x h_i := x .

Help Penchick determine the minimum number of operations needed to make the heights of the monument's pillars non-decreasing.

Format

Input

Each test contains multiple test cases. The first line contains the number of test cases t t ( 1t1000 1 \le t \le 1000 ). The description of the test cases follows.

The first line of each test case contains a single integer n n ( 1n50 1 \leq n \leq 50 ) — the number of pillars.

The second line of each test case contains n n integers h1,h2,,hn h_1, h_2, \ldots, h_n ( 1hin 1 \le h_i \le n and hihi+1 h_i\ge h_{i+1} ) — the height of the pillars.

Please take note that the given array h h is non-increasing.

Note that there are no constraints on the sum of n n over all test cases.

Output

For each test case, output a single integer representing the minimum number of operations needed to make the heights of the pillars non-decreasing.

Sample

3
5
5 4 3 2 1
3
2 2 1
1
1
4
1
0

ShanghaiTech ACM 炸鱼杯

未参加
状态
已结束
规则
OI
题目
46
开始于
2024-12-10 23:00
结束于
2024-12-15 13:00
持续时间
110 小时
主持人
参赛人数
112