Beautiful Sequence

아직 제출이 없습니다시간 제한3초메모리 제한1024 MB

문제

There is a sequence consisting of NN integers. We want to rearrange the integers to make the most beautiful sequence possible. A sequence is more beautiful when there are more members which are not less than their neighbors. The beauty of a sequence is the number of such members.

Write a program that will rearrange a given sequence to make it the most beautiful possible.

For example, if N=6N = 6 and the sequence is 1,1,2,3,3,41, 1, 2, 3, 3, 4, the beauty of the given sequence is 33. However, if we rearrange the sequence to become 2,1,3,3,1,42, 1, 3, 3, 1, 4, then the beauty of the rearranged sequence is 44, which is the maximum possible.

입력

The first line contains an integer TT, the number of test cases (1T22221 \le T \le 2222). The test cases follow.

The first line of each test case contains an integer NN, the number of elements (1N300,0001 \le N \le 300\\,000).

The next line contains the elements of the sequence. Each element is an integer between 11 and 10910^9, inclusive.

The sum of NN over all test cases does not exceed 5,000,0005\\,000\\,000.

출력

For each test case, print one line containing an integer: the highest beauty possible after rearrangement.