import sys

T = int(sys.stdin.readline())
for Ca in range(T):
    N = int(sys.stdin.readline())
    W = [int(i) for i in sys.stdin.readline().split(" ")]
    D = [-1 for i in range(141)]
    D[0] = 0 # D[i] stores the minimal weight of a tower of height i using only the first ants
    mh = 0
    for w in W: # adding an ant
        # finding the largest tower made of that ant could carry
        # by monotonicity it then can carry also all smaller towers 
        h = mh
        while(D[h] > 6 * w): #this stops as D[0]=0
            h -= 1
        if h == mh:
        	mh += 1
        # If it can carry: It might be possible to create a less heavy tower of height h2 + 1
        for h2 in range(h, -1, -1):
            if D[h2 + 1] == -1 or D[h2 + 1] > D[h2] + w:
                D[h2 + 1] = D[h2] + w
    print("Case #%i: %i" % (Ca+1, mh))