def make_divisors(n):

    divisors = []

    for i in range(1, int(n**0.5)+1):

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n//i)



    divisors.sort()

    return divisors



N,K = list(map(int,input().split()))

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

D = sum(A)

D = make_divisors(D)[::-1]



for d in D:

    a = []

    for i in range(N):

        a.append(A[i]%d)

    k = 0

    M = max(a)

    while k <= K and M != 0:

        i = 0

        j = 0

        m = d

        M = 0

        for l in range(N):

            if 0 < a[l] < m:

                m = a[l]

                i = l

        for l in range(N-1,-1,-1):

            if a[l] > M:

                M = a[l]

                j = l

        if m == d:

            break

        if m <= d-M:

            a[i] = 0

            a[j] += m

            a[j] %= d

            k += m

        else:

            a[i] -= d-M

            a[i] %= d

            a[j] = 0

            k += d-M

    if k <= K:

        break



print(d)
N,K = list(map(int,input().split()))

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

s = sum(A)



divisors = []

for i in range(1,int(s**0.5)+1):

    if s%i==0:

        divisors.append(i)

        divisors.append(s//i)

divisors = list(set(divisors))

divisors.sort(reverse=True)



def possible(n):

    a = []

    for i in range(N):

        if A[i]%n != 0:

            a.append(A[i]%n)

    a.sort()

    k = 0

    while k <= K and a:

        m = a[0]

        M = a[-1]

        if m <= n-M:

            k += m

            a[-1] = (M+m)%n

            a[0] = 0

        else:

            k += n-M

            a[0] = (m-n+M)%n

            a[-1] = 0

        if a[0]==0:

            a = a[1:]

        if a[-1]==0:

            a = a[:-1]

        a.sort()

    return k<=K



for n in divisors:

    if possible(n):

        ans = n

        break



print(ans)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors


N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
D = sum(A)
D = make_divisors(D)[::-1]
for d in D:
    a = []
    for i in range(N):
        a.append(A[i] % d)
    k = 0
    M = max(a)
    while k <= K and M != 0:
        i = 0
        j = 0
        m = d
        M = 0
        for l in range(N):
            if 0 < a[l] < m:
                m = a[l]
                i = l
        for l in range(N - 1, -1, -1):
            if a[l] > M:
                M = a[l]
                j = l
        if m == d:
            break
        if m <= d - M:
            a[i] = 0
            a[j] += m
            a[j] %= d
            k += m
        else:
            a[i] -= d - M
            a[i] %= d
            a[j] = 0
            k += d - M
    if k <= K:
        break
print(d)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
s = sum(A)
divisors = []
for i in range(1, int(s**0.5) + 1):
    if s % i == 0:
        divisors.append(i)
        divisors.append(s // i)
divisors = list(set(divisors))
divisors.sort(reverse=True)


def possible(n):
    a = []
    for i in range(N):
        if A[i] % n != 0:
            a.append(A[i] % n)
    a.sort()
    k = 0
    while k <= K and a:
        m = a[0]
        M = a[-1]
        if m <= n - M:
            k += m
            a[-1] = (M + m) % n
            a[0] = 0
        else:
            k += n - M
            a[0] = (m - n + M) % n
            a[-1] = 0
        if a[0] == 0:
            a = a[1:]
        if a[-1] == 0:
            a = a[:-1]
        a.sort()
    return k <= K


for n in divisors:
    if possible(n):
        ans = n
        break
print(ans)

-def make_divisors(n): -    divisors = [] -    for i in range(1, int(n**0.5) + 1): -        if n % i == 0: -            divisors.append(i) -            if i != n // i: -                divisors.append(n // i) -    divisors.sort() -    return divisors +N, K = list(map(int, input().split())) +A = list(map(int, input().split())) +s = sum(A) +divisors = [] +for i in range(1, int(s**0.5) + 1): +    if s % i == 0: +        divisors.append(i) +        divisors.append(s // i) +divisors = list(set(divisors)) +divisors.sort(reverse=True) -N, K = list(map(int, input().split())) -A = list(map(int, input().split())) -D = sum(A) -D = make_divisors(D)[::-1] -for d in D: +def possible(n): -        a.append(A[i] % d) +        if A[i] % n != 0: +            a.append(A[i] % n) +    a.sort() -    M = max(a) -    while k <= K and M != 0: -        i = 0 -        j = 0 -        m = d -        M = 0 -        for l in range(N): -            if 0 < a[l] < m: -                m = a[l] -                i = l -        for l in range(N - 1, -1, -1): -            if a[l] > M: -                M = a[l] -                j = l -        if m == d: -            break -        if m <= d - M: -            a[i] = 0 -            a[j] += m -            a[j] %= d +    while k <= K and a: +        m = a[0] +        M = a[-1] +        if m <= n - M: +            a[-1] = (M + m) % n +            a[0] = 0 -            a[i] -= d - M -            a[i] %= d -            a[j] = 0 -            k += d - M -    if k <= K: +            k += n - M +            a[0] = (m - n + M) % n +            a[-1] = 0 +        if a[0] == 0: +            a = a[1:] +        if a[-1] == 0: +            a = a[:-1] +        a.sort() +    return k <= K + + +for n in divisors: +    if possible(n): +        ans = n -print(d) +print(ans)