def main():

    N, K = (int(i) for i in input().split())

    A = [int(i) for i in input().split()]

    sumA = sum(A)



    def trial_division(n):

        divs = []

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

            if n % i == 0:

                divs.append(i)

                if i != n//i:

                    divs.append(n//i)

        return divs



    from itertools import accumulate

    divs = trial_division(sumA)

    ans = 0

    for d in divs:

        R = [a % d for a in A if a % d != 0]

        R.sort()

        S = [acc for acc in accumulate(R)]

        M = len(S)

        # print(d, R, S)

        if M == 0:

            ans = max(ans, d)

            continue

        for i in range(M-1):

            ne = S[i]

            po = d*(M-1-i) - (S[M-1] - S[i])

            if po == ne and po <= K:

                ans = max(ans, d)

    print(ans)





if __name__ == '__main__':

    main()

def main():

    from itertools import accumulate

    N, K = (int(i) for i in input().split())

    A = [int(i) for i in input().split()]

    sumA = sum(A)



    def enum_divisors(n):

        # 約数列挙

        divs = []

        for i in range(1, n+1):

            if i*i > n:

                break

            if n % i == 0:

                divs.append(i)

                if n//i != i:

                    # i が平方数でない

                    divs.append(n//i)

        return divs



    divs = enum_divisors(sumA)

    divs.sort(reverse=True)



    for d in divs:

        if d == 1:

            print(d)

            return

        diff_n = []

        for a in A:

            if a % d != 0:

                diff_n.append(a % d)

        diff_n.sort()

        diff_p = []

        for dn in diff_n:

            diff_p.append(d - dn)

        S_n = list(accumulate([0] + diff_n))

        S_p = list(accumulate([0] + diff_p))

        M = len(S_n) - 1

        if min(S_n[i] for i in range(1, M)

               if (S_n[i] - (S_p[M] - S_p[i])) == 0) <= K:

            print(d)

            return





if __name__ == '__main__':

    main()

def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sumA = sum(A)

    def trial_division(n):
        divs = []
        for i in range(1, int(n**0.5) + 1):
            if n % i == 0:
                divs.append(i)
                if i != n // i:
                    divs.append(n // i)
        return divs

    from itertools import accumulate

    divs = trial_division(sumA)
    ans = 0
    for d in divs:
        R = [a % d for a in A if a % d != 0]
        R.sort()
        S = [acc for acc in accumulate(R)]
        M = len(S)
        # print(d, R, S)
        if M == 0:
            ans = max(ans, d)
            continue
        for i in range(M - 1):
            ne = S[i]
            po = d * (M - 1 - i) - (S[M - 1] - S[i])
            if po == ne and po <= K:
                ans = max(ans, d)
    print(ans)


if __name__ == "__main__":
    main()

def main():
    from itertools import accumulate

    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sumA = sum(A)

    def enum_divisors(n):
        # 約数列挙
        divs = []
        for i in range(1, n + 1):
            if i * i > n:
                break
            if n % i == 0:
                divs.append(i)
                if n // i != i:
                    # i が平方数でない
                    divs.append(n // i)
        return divs

    divs = enum_divisors(sumA)
    divs.sort(reverse=True)
    for d in divs:
        if d == 1:
            print(d)
            return
        diff_n = []
        for a in A:
            if a % d != 0:
                diff_n.append(a % d)
        diff_n.sort()
        diff_p = []
        for dn in diff_n:
            diff_p.append(d - dn)
        S_n = list(accumulate([0] + diff_n))
        S_p = list(accumulate([0] + diff_p))
        M = len(S_n) - 1
        if min(S_n[i] for i in range(1, M) if (S_n[i] - (S_p[M] - S_p[i])) == 0) <= K:
            print(d)
            return


if __name__ == "__main__":
    main()

+    from itertools import accumulate + -    def trial_division(n): +    def enum_divisors(n): +        # 約数列挙 -        for i in range(1, int(n**0.5) + 1): +        for i in range(1, n + 1): +            if i * i > n: +                break -                if i != n // i: +                if n // i != i: +                    # i が平方数でない -    from itertools import accumulate - -    divs = trial_division(sumA) -    ans = 0 +    divs = enum_divisors(sumA) +    divs.sort(reverse=True) -        R = [a % d for a in A if a % d != 0] -        R.sort() -        S = [acc for acc in accumulate(R)] -        M = len(S) -        # print(d, R, S) -        if M == 0: -            ans = max(ans, d) -            continue -        for i in range(M - 1): -            ne = S[i] -            po = d * (M - 1 - i) - (S[M - 1] - S[i]) -            if po == ne and po <= K: -                ans = max(ans, d) -    print(ans) +        if d == 1: +            print(d) +            return +        diff_n = [] +        for a in A: +            if a % d != 0: +                diff_n.append(a % d) +        diff_n.sort() +        diff_p = [] +        for dn in diff_n: +            diff_p.append(d - dn) +        S_n = list(accumulate([0] + diff_n)) +        S_p = list(accumulate([0] + diff_p)) +        M = len(S_n) - 1 +        if min(S_n[i] for i in range(1, M) if (S_n[i] - (S_p[M] - S_p[i])) == 0) <= K: +            print(d) +            return