Public Judge

pjudge

时间限制: 1 s 内存限制: 512 MB 总分: 100 可 Hack ✓
统计

Given a sequence of $n$ positive integers $a_1, \dots, a_n$.

You can perform several operations. In each operation, you can choose an index $i \in [2, n-1]$ such that $a_i = \frac{a_{i-1} + a_{i+1}}{2}$, then remove $a_i$ from the sequence, and shift the subsequent elements forward to fill the gap.

Find the minimum possible length of the sequence after performing any number of operations.

Input

The first line contains a positive integer $T$, representing the number of test cases. For each test case:

  • The first line contains a positive integer $n$;
  • The second line contains $n$ positive integers $a_1, \dots, a_n$.

Output

For each test case, output a single line containing a positive integer representing the answer.

Examples

Input 1

3
5
1 2 3 4 5
7
1 3 5 6 7 8 10
3
1 1 1

Output 1

2
4
2

Note

For the first test case $[1, 2, 3, 4, 5]$, you can remove $2, 4, 3$ in sequence.

For the second test case $[1, 3, 5, 6, 7, 8, 10]$, you can remove $3, 7, 8$ in sequence.

For the third test case $[1, 1, 1]$, you can remove the middle $1$.

Input 2

(input data)

Output 2

(output data)

Constraints

For all data, $n \ge 3$, $1 \le T \le 10^3$, $\sum n \le 3 \cdot 10^5$, $1 \le a_i \le 10^9$.

Test Case ID $n \le$ $\sum n \le$ Special Property
$1 \sim 3$ $15$ $400$
$4 \sim 6$ $a_i=i$
$7 \sim 8$ $a_i \le 3$
$9 \sim 12$ $300$ $10^3$
$13 \sim 16$ $3 \cdot 10^3$ $10^4$
$17 \sim 20$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.