d1000000

아직 제출이 없습니다메모리 제한1024 MB

문제

While the most typical type of dice have 66 sides, each of which shows a different integer 11 through 66, there are many games that use other types. In particular, a dkdk is a die with kk sides, each of which shows a different integer 11 through kk. A d6d6 is a typical die, a d4d4 has four sides, and a d1000000d1000000 has one million sides.

In this problem, we start with a collection of NN dice. The ii-th die is a dS_idS\_i, that is, it has S_iS\_i sides showing integers 11 through S_iS\_i. A straight of length starting at xx is the list of integers x,x+1,,x+(1)x,x+1,\dots ,x+(ℓ-1). We want to choose some of the dice (possibly all) and pick one number from each to form a straight. What is the longest straight we can form in this way?

입력

The first line of the input gives the number of test cases, TT. TT test cases follow. Each test case is described in two lines. The first line of a test case contains a single integer NN, the number of dice in the game. The second line contains NN integers S_1,S_2,,S_NS\_1,S\_2, \dots ,S\_N, each representing the number of sides of a different die.

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the maximum number of input dice that can be put in a straight.

제한

  • 1T1001≤T≤100.

힌트

In Sample Case #1, there are multiple ways to form a straight using all 44 dice. One possible way is shown in the image above.

In Sample Case #2, since none of the dice can show an integer greater than 55, there is no way to have a straight with more than 55 dice. There are multiple ways to form a straight with exactly 55 dice. For example, pick the integers 44 and 55 for both d5d5⁠'s and then integers 11, 22, and 33 for three of the d4d4⁠'s to form 11, 22, 33, 44, 55.

In Sample Case #3, it is possible to form the straight 11, 22, 33, 44, 55, 66, 77, 88, 99 by discarding one d4d4 and using the d4d4⁠'s, d5d5, and d6d6 to get 11 through 44; the d7d7⁠'s to get 55 through 77; and the d10d10⁠'s to get 88 and 99. There is no way to form a straight of length 1010, so this is the best that can be done.

In Sample Case #4, we can only form a straight of length 11, but we can do so by picking any integer for the d10d10 we are given.