str = gets.split
N,K = str[0].to_i, str[1].to_i
a = Array.new(N)
sum = 0
str = gets.split
for i in 0...N do
    a[i] = str[i].to_i
    sum += a[i]
end
b = Array.new(0)

x = 1
l = 0
r = 0
ll = Array.new(0)
rr = Array.new(0)
empty = Array.new(0)
c = 0
y = 0
z = 0
max = 0
min = 0
while sum/x >= x
    if sum % x == 0
        y = sum/x
        if x != y
            b.push(x) 
        end
        l = 0
        r = 0
        ll = empty
        rr = empty
        for i in 0...N do
            z = a[i] % y
            if z*2 == y
                c += 1
            elsif z*2 < y
                l += z
                ll.push(y-z)
            else
                r += (y-z)
                rr.push(z)
            end
        end
        while c > 0
            if l < r
                l += y/2
            else
                r += y/2
            end
            c -= 1
        end
        z = (l-r).abs/y
        if l>r
            ll.sort!
            ll.reverse!
            while z > 0
                r += ll.pop
                z -= 1
            end
        else
            rr.sort!
            rr.reverse!
            while z > 0
                l += rr.pop
                z -= 1
            end
        end
        if l<=K || r<=K
            puts y
            exit
        end
    end
    x += 1
end
while !b.empty?
    y = b.pop
    l = 0
    r = 0
    ll = empty
    rr = empty
    for i in 0...N do
    z = a[i] % y
        if z*2 == y
            c += 1
        elsif z*2 < y
            l += z
            ll.push(y-z)
        else
            r += (y-z)
            rr.push(z)
        end
    end
    while c > 0
        if l < r
            l += y/2
        else
            r += y/2
        end
        c -= 1
    end
    z = (l-r).abs/y
    if l>r
        ll.sort!
        ll.reverse!
        while z > 0
            r += ll.pop
            z -= 1
        end
    else
        rr.sort!
        rr.reverse!
        while z > 0
            l += rr.pop
            z -= 1
        end
    end
    if l<=K || r<=K
        puts y
        exit
    end
end