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

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



sum_a=sum(alist)

alist.sort()

#print(sum_a,alist)



#M=1の場合にも対応

divisor_set=set()

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

  if sum_a%i==0:

    divisor_set.add(i)

    divisor_set.add(sum_a//i)

divisor_list=list(divisor_set)

divisor_list.sort()

#print(divisor_list)



answer=0

for d in divisor_list:

  rlist=[]

  for a in alist:

    rlist.append((a%d,(d-a%d)%d))

  rlist.sort()

  

  r1list,r2list=[],[]

  for r1,r2 in rlist:

    r1list.append(r1)

    r2list.append(r2)  

  #print(d,r1list,r2list)

  

  for i in range(len(rlist)):

    r1sum=sum(r1list[:i])

    r2sum=sum(r2list[i:])

    if r1sum==r2sum and r1sum<=K:

      answer=d

      break

      

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

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



sum_a=sum(alist)

alist.sort()

#print(sum_a,alist)



#M=1の場合にも対応

divisor_set=set()

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

  if sum_a%i==0:

    divisor_set.add(i)

    divisor_set.add(sum_a//i)

divisor_list=list(divisor_set)

divisor_list.sort()

#print(divisor_list)



answer=0

for d in divisor_list:

  rlist=[]

  for a in alist:

    rlist.append((a%d,(d-a%d)%d))

  rlist.sort()

  

  s1list,s2list=[0],[0]

  for r1,r2 in rlist:

    s1list.append(s1list[-1]+r1)

    s2list.append(s2list[-1]+r2)

  #print(d,s1list,s2list)

  

  for i in range(len(rlist)):

    r1sum=s1list[i]

    r2sum=s2list[-1]-s2list[i]

    if r1sum==r2sum and r1sum<=K:

      answer=d

      break

      

print(answer)
N, K = list(map(int, input().split()))
alist = list(map(int, input().split()))
sum_a = sum(alist)
alist.sort()
# print(sum_a,alist)
# M=1の場合にも対応
divisor_set = set()
for i in range(1, int(sum_a**0.5) + 1):
    if sum_a % i == 0:
        divisor_set.add(i)
        divisor_set.add(sum_a // i)
divisor_list = list(divisor_set)
divisor_list.sort()
# print(divisor_list)
answer = 0
for d in divisor_list:
    rlist = []
    for a in alist:
        rlist.append((a % d, (d - a % d) % d))
    rlist.sort()
    r1list, r2list = [], []
    for r1, r2 in rlist:
        r1list.append(r1)
        r2list.append(r2)
    # print(d,r1list,r2list)
    for i in range(len(rlist)):
        r1sum = sum(r1list[:i])
        r2sum = sum(r2list[i:])
        if r1sum == r2sum and r1sum <= K:
            answer = d
            break
print(answer)

N, K = list(map(int, input().split()))
alist = list(map(int, input().split()))
sum_a = sum(alist)
alist.sort()
# print(sum_a,alist)
# M=1の場合にも対応
divisor_set = set()
for i in range(1, int(sum_a**0.5) + 1):
    if sum_a % i == 0:
        divisor_set.add(i)
        divisor_set.add(sum_a // i)
divisor_list = list(divisor_set)
divisor_list.sort()
# print(divisor_list)
answer = 0
for d in divisor_list:
    rlist = []
    for a in alist:
        rlist.append((a % d, (d - a % d) % d))
    rlist.sort()
    s1list, s2list = [0], [0]
    for r1, r2 in rlist:
        s1list.append(s1list[-1] + r1)
        s2list.append(s2list[-1] + r2)
    # print(d,s1list,s2list)
    for i in range(len(rlist)):
        r1sum = s1list[i]
        r2sum = s2list[-1] - s2list[i]
        if r1sum == r2sum and r1sum <= K:
            answer = d
            break
print(answer)

-    r1list, r2list = [], [] +    s1list, s2list = [0], [0] -        r1list.append(r1) -        r2list.append(r2) -    # print(d,r1list,r2list) +        s1list.append(s1list[-1] + r1) +        s2list.append(s2list[-1] + r2) +    # print(d,s1list,s2list) -        r1sum = sum(r1list[:i]) -        r2sum = sum(r2list[i:]) +        r1sum = s1list[i] +        r2sum = s2list[-1] - s2list[i]