CF1764B.Doremy's Perfect Math Class

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

Doremy's Perfect Math Class

"Everybody! Doremy's Perfect Math Class is about to start! Come and do your best if you want to have as much IQ as me!" In today's math class, Doremy is teaching everyone subtraction. Now she gives you a quiz to prove that you are paying attention in class.

You are given a set SS containing positive integers. You may perform the following operation some (possibly zero) number of times:

  • choose two integers xx and yy from the set SS such that x>yx \gt y and xyx - y is not in the set SS.
  • add xyx-y into the set SS.

You need to tell Doremy the maximum possible number of integers in SS if the operations are performed optimally. It can be proven that this number is finite.

Input

The input consists of multiple test cases. The first line contains a single integer tt (1t1041\le t\le 10^4) — the number of test cases. The description of the test cases follows.

The first line contains an integer nn (2n1052 \le n\le 10^5) — the size of the set SS.

The second line contains nn integers a1,a2,,ana_1,a_2,\dots,a_n (1a1<a2<<an1091\le a_1 \lt a_2 \lt \cdots \lt a_n \le 10^9) — the positive integers in SS.

It is guaranteed that the sum of nn over all test cases does not exceed 21052\cdot 10^5.

Output

For each test case, you need to output the maximum possible number of integers in SS. It can be proven that this value is finite.

Note

In the first test case, no such xx and yy exist. The maximum possible number of integers in SS is 22.

In the second test case,

  • S={5,10,25}S=\{5,10,25\} at first. You can choose x=25x=25, y=10y=10, then add xy=15x-y=15 to the set.
  • S={5,10,15,25}S=\{5,10,15,25\} now. You can choose x=25x=25, y=5y=5, then add xy=20x-y=20 to the set.
  • S={5,10,15,20,25}S=\{5,10,15,20,25\} now. You can not perform any operation now.

After performing all operations, the number of integers in SS is 55. It can be proven that no other sequence of operations allows SS to contain more than 55 integers.

Samples

2
2
1 2
3
5 10 25
2
5

在线编程 IDE

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