T = 10

for t in range(1, T+1):
    dump = int(input())
    h_list = list(map(int, input().split()))

    cnt_list = [0 for _ in range(101)]

    for h in h_list:
        cnt_list[h] += 1

    l = 1
    r = 100

    while True:
        while cnt_list[r] == 0:
            r -= 1

        while cnt_list[l] == 0:
            l += 1

        if dump <= 0:
            break

        cnt_list[r] -= 1
        cnt_list[l] -= 1

        cnt_list[r - 1] += 1
        cnt_list[l + 1] += 1
        dump -= 1

    result = r - l
    print('#{} {}'.format(t, result))

+ Recent posts