CF1749C.Number Game

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

Number Game

Alice and Bob are playing a game. They have an array of positive integers aa of size nn.

Before starting the game, Alice chooses an integer k0k \ge 0. The game lasts for kk stages, the stages are numbered from 11 to kk. During the ii-th stage, Alice must remove an element from the array that is less than or equal to ki+1k - i + 1. After that, if the array is not empty, Bob must add ki+1k - i + 1 to an arbitrary element of the array. Note that both Alice's move and Bob's move are two parts of the same stage of the game. If Alice can't delete an element during some stage, she loses. If the kk-th stage ends and Alice hasn't lost yet, she wins.

Your task is to determine the maximum value of kk such that Alice can win if both players play optimally. Bob plays against Alice, so he tries to make her lose the game, if it's possible.

Input

The first line contains a single integer tt (1t1001 \le t \le 100) — the number of test cases.

The first line of each test case contains a single integer nn (1n1001 \le n \le 100) — the size of the array aa.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ain1 \le a_i \le n).

Output

For each test case, print one integer — the maximum value of kk such that Alice can win if both players play optimally.

Samples

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

在线编程 IDE

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