def max2(x,y):

    return x if x > y else y



def divisors(n):

    i = 1

    table = set()

    while i * i <= n:

        if not n % i:

            table.add(i)

            table.add(n//i)

        i += 1

    table = list(table)

    return table



import numpy as np

import sys

input = sys.stdin.readline



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

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

S = sum(A)

D = divisors(S)

D.sort()

res = 0

for k in D:

    B = A%k

    B.sort()

    cnt = sum(B)//k

    if k*cnt - sum(B[-cnt:]) <= K:

        res = max2(res, k)



print(res)
def divisors(n):

    i = 1

    table = set()

    while i * i <= n:

        if not n % i:

            table.add(i)

            table.add(n//i)

        i += 1

    table = list(table)

    return table



def binary_search_int(ok, ng, test):

    """

    :param ok: solve(x) = True を必ず満たす点

    :param ng: solve(x) = False を必ず満たす点

    """

    while abs(ok - ng) > 1:

        mid = (ok + ng) // 2

        if test(mid):

            ok = mid

        else:

            ng = mid

    return ok



import sys

input = sys.stdin.readline



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

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

S = sum(A)

D = divisors(S)

D.sort()



def test(x):

    k = D[x]

    B = []

    for a in A:

        B.append(a%k)

    B.sort()

    cnt = sum(B)//k

    return k*cnt - sum(B[-cnt:]) <= K



p = binary_search_int(0,len(D),test)

q = binary_search_int(p+1,len(D),test)

print((max(D[p],D[q]) if q != p+1 else D[p]))
def max2(x, y):
    return x if x > y else y


def divisors(n):
    i = 1
    table = set()
    while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n // i)
        i += 1
    table = list(table)
    return table


import numpy as np
import sys

input = sys.stdin.readline
N, K = list(map(int, input().split()))
A = np.array(list(map(int, input().split())))
S = sum(A)
D = divisors(S)
D.sort()
res = 0
for k in D:
    B = A % k
    B.sort()
    cnt = sum(B) // k
    if k * cnt - sum(B[-cnt:]) <= K:
        res = max2(res, k)
print(res)

def divisors(n):
    i = 1
    table = set()
    while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n // i)
        i += 1
    table = list(table)
    return table


def binary_search_int(ok, ng, test):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if test(mid):
            ok = mid
        else:
            ng = mid
    return ok


import sys

input = sys.stdin.readline
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
S = sum(A)
D = divisors(S)
D.sort()


def test(x):
    k = D[x]
    B = []
    for a in A:
        B.append(a % k)
    B.sort()
    cnt = sum(B) // k
    return k * cnt - sum(B[-cnt:]) <= K


p = binary_search_int(0, len(D), test)
q = binary_search_int(p + 1, len(D), test)
print((max(D[p], D[q]) if q != p + 1 else D[p]))

-def max2(x, y): -    return x if x > y else y - - -import numpy as np +def binary_search_int(ok, ng, test): +    """ +    :param ok: solve(x) = True を必ず満たす点 +    :param ng: solve(x) = False を必ず満たす点 +    """ +    while abs(ok - ng) > 1: +        mid = (ok + ng) // 2 +        if test(mid): +            ok = mid +        else: +            ng = mid +    return ok + + -A = np.array(list(map(int, input().split()))) +A = list(map(int, input().split())) -res = 0 -for k in D: -    B = A % k + + +def test(x): +    k = D[x] +    B = [] +    for a in A: +        B.append(a % k) -    if k * cnt - sum(B[-cnt:]) <= K: -        res = max2(res, k) -print(res) +    return k * cnt - sum(B[-cnt:]) <= K + + +p = binary_search_int(0, len(D), test) +q = binary_search_int(p + 1, len(D), test) +print((max(D[p], D[q]) if q != p + 1 else D[p]))