# https://atcoder.jp/contests/abc136/submissions/6708242



def solve():

    n, k = list(map(int, input().split()))

    a = tuple(sorted(map(int, input().split()), reverse=True))



    sum_a = sum(a)

    e = set()

    divisor = 1

    while divisor * divisor <= sum_a:

        if sum_a % divisor == 0:

            e.add(divisor)

            e.add(sum_a // divisor)

        divisor += 1



    e = sorted(e, reverse=True)

    # 約数降順



    for cand in e:

        r = tuple(sorted(x % cand for x in a if x % cand != 0))



        accm = [0]

        t = 0

        for x in r:

            t += x

            accm.append(t)



        accp = [0]

        t = 0

        for x in r:

            t += cand - x

            accp.append(t)



        m = len(r)

        for i in range(m + 1):

            if (accm[i] == (accp[m] - accp[i])) and (accm[i] <= k):

                return cand

    return -1





print((solve()))



# 操作で総和は不変

# https://betrue12.hateblo.jp/entry/2020/03/28/142051



def main():

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

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



    def divisor_generator(n):

        div = 1



        stock = []

        while div * div <= n:

            if n % div == 0:

                yield n // div

                stock.append(div)

            div += 1



        for div in reversed(stock):

            yield div



    tot = sum(A)

    for div in divisor_generator(tot):

        k = tot // div - sum(a // div for a in A)

        R = sorted(a % div for a in A)

        Rc = [div - r for r in R]



        cond = (sr := sum(r for r in R[:N - k])) == sum(r for r in Rc[N - k:]) and sr <= K

        if cond:

            print(div)

            return





if __name__ == '__main__':

    main()

# https://atcoder.jp/contests/abc136/submissions/6708242
def solve():
    n, k = list(map(int, input().split()))
    a = tuple(sorted(map(int, input().split()), reverse=True))
    sum_a = sum(a)
    e = set()
    divisor = 1
    while divisor * divisor <= sum_a:
        if sum_a % divisor == 0:
            e.add(divisor)
            e.add(sum_a // divisor)
        divisor += 1
    e = sorted(e, reverse=True)
    # 約数降順
    for cand in e:
        r = tuple(sorted(x % cand for x in a if x % cand != 0))
        accm = [0]
        t = 0
        for x in r:
            t += x
            accm.append(t)
        accp = [0]
        t = 0
        for x in r:
            t += cand - x
            accp.append(t)
        m = len(r)
        for i in range(m + 1):
            if (accm[i] == (accp[m] - accp[i])) and (accm[i] <= k):
                return cand
    return -1


print((solve()))
# 操作で総和は不変

# https://betrue12.hateblo.jp/entry/2020/03/28/142051
def main():
    N, K = list(map(int, input().split()))
    (*A,) = list(map(int, input().split()))

    def divisor_generator(n):
        div = 1
        stock = []
        while div * div <= n:
            if n % div == 0:
                yield n // div
                stock.append(div)
            div += 1
        for div in reversed(stock):
            yield div

    tot = sum(A)
    for div in divisor_generator(tot):
        k = tot // div - sum(a // div for a in A)
        R = sorted(a % div for a in A)
        Rc = [div - r for r in R]
        cond = (sr := sum(r for r in R[: N - k])) == sum(
            r for r in Rc[N - k :]
        ) and sr <= K
        if cond:
            print(div)
            return


if __name__ == "__main__":
    main()

-# https://atcoder.jp/contests/abc136/submissions/6708242 -def solve(): -    n, k = list(map(int, input().split())) -    a = tuple(sorted(map(int, input().split()), reverse=True)) -    sum_a = sum(a) -    e = set() -    divisor = 1 -    while divisor * divisor <= sum_a: -        if sum_a % divisor == 0: -            e.add(divisor) -            e.add(sum_a // divisor) -        divisor += 1 -    e = sorted(e, reverse=True) -    # 約数降順 -    for cand in e: -        r = tuple(sorted(x % cand for x in a if x % cand != 0)) -        accm = [0] -        t = 0 -        for x in r: -            t += x -            accm.append(t) -        accp = [0] -        t = 0 -        for x in r: -            t += cand - x -            accp.append(t) -        m = len(r) -        for i in range(m + 1): -            if (accm[i] == (accp[m] - accp[i])) and (accm[i] <= k): -                return cand -    return -1 +# https://betrue12.hateblo.jp/entry/2020/03/28/142051 +def main(): +    N, K = list(map(int, input().split())) +    (*A,) = list(map(int, input().split())) + +    def divisor_generator(n): +        div = 1 +        stock = [] +        while div * div <= n: +            if n % div == 0: +                yield n // div +                stock.append(div) +            div += 1 +        for div in reversed(stock): +            yield div + +    tot = sum(A) +    for div in divisor_generator(tot): +        k = tot // div - sum(a // div for a in A) +        R = sorted(a % div for a in A) +        Rc = [div - r for r in R] +        cond = (sr := sum(r for r in R[: N - k])) == sum( +            r for r in Rc[N - k :] +        ) and sr <= K +        if cond: +            print(div) +            return -print((solve())) -# 操作で総和は不変 +if __name__ == "__main__": +    main()