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):

        if A[i]%d != 0:

            a.append(A[i]%d)

    a.sort()

    b = [d-x for x in a]

    b.sort()



    c1 = [0]*(len(a)+1)

    for i in range(len(a)):

        c1[i] = a[i]+c1[i-1]

    c2 = [0]*(len(b)+1)

    for i in range(len(b)):

        c2[i] = b[i]+c2[i-1]



    k = float('inf')

    for i in range(len(a)):

        if c1[i] == c2[len(a)-2-i]:

            k = c1[i]

            break

    if k <= K:

        break

print(d)
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)
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):
        if A[i] % d != 0:
            a.append(A[i] % d)
    a.sort()
    b = [d - x for x in a]
    b.sort()
    c1 = [0] * (len(a) + 1)
    for i in range(len(a)):
        c1[i] = a[i] + c1[i - 1]
    c2 = [0] * (len(b) + 1)
    for i in range(len(b)):
        c2[i] = b[i] + c2[i - 1]
    k = float("inf")
    for i in range(len(a)):
        if c1[i] == c2[len(a) - 2 - i]:
            k = c1[i]
            break
    if k <= K:
        break
print(d)

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)

-        if A[i] % d != 0: -            a.append(A[i] % d) -    a.sort() -    b = [d - x for x in a] -    b.sort() -    c1 = [0] * (len(a) + 1) -    for i in range(len(a)): -        c1[i] = a[i] + c1[i - 1] -    c2 = [0] * (len(b) + 1) -    for i in range(len(b)): -        c2[i] = b[i] + c2[i - 1] -    k = float("inf") -    for i in range(len(a)): -        if c1[i] == c2[len(a) - 2 - i]: -            k = c1[i] +        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: +        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