CF2175A.Little Fairy's Painting

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

Little Fairy's Painting

The little fairy has a ribbon with 101810^{18} cells and an infinite variety of colors. The first nn cells of the ribbon have already been colored, where the ii-th cell is colored with color aia_i.

Little fairy will color the remaining cells in order from n+1n+1 to 101810^{18}. For the ii-th cell:

  • Little fairy first counts the number of distinct colors currently present on the ribbon, denoted as cic_i.
  • Then she will color the ii-th cell with color cic_i.

What color will the fairy use for the 101810^{18}-th cell?

Input

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

The first line of each test case contains a single integer nn (1n1001 \le n \le 100) — the number of colored cells.

The second line of each test case contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (1ai1031 \le a_i \le 10^3) — the colors of the cells.

Output

For each test case, print the color of the last cell.

Note

In the first example, each time there is only one distinct color on the ribbon, so the fairy always chooses the color 11.

In the second example, the fairy will color the next 10001000 cells with colors from 11 to 10001000 sequentially, after that all next cells will be colored with color 10001000.

Samples

5
6
1 1 1 1 1 1
1
1000
5
8 10 15 20 25
8
2 5 2 4 1 2 5 3
6
40 4 1 95 8 40
1
1000
8
5
8

在线编程 IDE

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