n = int(eval(input()))

a = list(map(int, input().split()))



a.sort()

ans = 0

while a[-1] >= n:

    k = -(-(a[-1]+1)//n)-1

    ans += k

    for i in range(n-1):

        a[i] += k

    a[-1] -= n*k

    a.sort()



print(ans)
n = int(eval(input()))

a = list(map(int, input().split()))



ans = 0

while True:

    tmp = 0

    for i in range(n):

        k = -(-(a[i]+1)//n)-1

        tmp += k

        a[i] -= k*n

        a[i] -= k

    for i in range(n):

        a[i] += tmp

    if not tmp:

        break

    ans += tmp



print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
ans = 0
while a[-1] >= n:
    k = -(-(a[-1] + 1) // n) - 1
    ans += k
    for i in range(n - 1):
        a[i] += k
    a[-1] -= n * k
    a.sort()
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
while True:
    tmp = 0
    for i in range(n):
        k = -(-(a[i] + 1) // n) - 1
        tmp += k
        a[i] -= k * n
        a[i] -= k
    for i in range(n):
        a[i] += tmp
    if not tmp:
        break
    ans += tmp
print(ans)

-a.sort() -while a[-1] >= n: -    k = -(-(a[-1] + 1) // n) - 1 -    ans += k -    for i in range(n - 1): -        a[i] += k -    a[-1] -= n * k -    a.sort() +while True: +    tmp = 0 +    for i in range(n): +        k = -(-(a[i] + 1) // n) - 1 +        tmp += k +        a[i] -= k * n +        a[i] -= k +    for i in range(n): +        a[i] += tmp +    if not tmp: +        break +    ans += tmp