CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
H = list(map(int, input().split()))
ABS = []
for i in H:
    ABS.append(abs((t-i*0.006) - a))
print((ABS.index(min(ABS)) + 1))

# Optimized solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
H = list(map(int, input().split()))
mtd = 1000
for i in range(n):
    if abs(a - (t - (H[i] * 0.006))) < mtd:
        mtd = abs(a - (t - (H[i] * 0.006)))
        ans = i + 1
print(ans)
# Original solution
import sys
 
def solve(N, T, A, ls_H):
    dosi = []
    titen = []
    titen1 = []
    ti = 10**5//1
    for x in ls_H :
        do = T - x * 0.006
        dosi.append(do)
    #print(dosi)
    
    for y in dosi :
        til = A - y
        titen.append(til)
    #print(titen)
    
    for z in titen :
        titen1.append(abs(z))
    #print(titen1)
    
    for i in titen1 :
        if ti > i :
            ti = i
    #print(ti)
    return titen1.index(ti) + 1
 
def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)
 
def main():
    print((solve(*readQuestion())))
 # Uncomment before submission
main()

# Optimized solution
import sys
 
def solve(N, T, A, ls_H):
    temperature = []
    difference = []
    near = []
    ti = 10**5//1
    for x in ls_H :
        air = T - x * 0.006
        temperature.append(air)
    #print(temperature)
    
    for y in temperature :
        til = A - y
        difference.append(til)
    #print(difference)
    
    for z in difference :
        near.append(abs(z))
    #print(near)
    
    for i in near :
        if ti > i :
            ti = i
    #print(ti)
    return near.index(ti) + 1


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)
 
def main():
    print((solve(*readQuestion())))
 # Uncomment before submission
main()
# Original solution
N = int(eval(input()))
T,A = list(map(int,input().split()))
now = 10000000
ans = 0
H = list(map(int,input().split()))
for i in range(N):
    tmp = T - H[i]*0.006
    if abs(A - tmp) < now:
        now = abs(A - tmp)
        ans = i+1
print(ans)

# Optimized solution
N = int(eval(input()))
T,A = list(map(int,input().split()))
H = list(map(int,input().split()))
now = 99999
ans = 0
for i in range(N):
  tem = T - H[i] * 0.006
  if abs(tem - A ) < now:
    now = abs(tem - A)
    ans = i+1
print(ans)
# Original solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))

res = 0
cc = float('inf')
for i in range(n):
    d = (1000 * t - 6 * h[i]) - 1000 * a
    if d < 0: d = -d
    if cc > d:
        cc = d
        res = i + 1
print(res)

# Optimized solution
N = int(eval(input()))
T, A = list(map(int, input().split()))
h = list(map(int, input().split()))

d = 10 ** 9
ans = -1
for i in range(N):
    t = abs((1000 * T - 6 * h[i]) - 1000 * A)
    if t < d:
        ans = i + 1
        d = t
print(ans)
# Original solution
n=int(eval(input()))
t,a=list(map(int,input().split()))
hi=[int(_) for _ in input().split()]
z=[abs(a-(t-x*0.006)) for x in hi]
print((z.index(min(z))+1))

# Optimized solution
n=int(eval(input()))
t,a=list(map(int,input().split()))
h=list(map(int,input().split()))
z=[abs(t-x*0.006-a) for x in h]
print((z.index(min(z))+1))
# Original solution
N = int(eval(input()))
T,A = list(map(int,input().split()))
H = list(map(int,input().split()))
 
x = 100000
ans = 0
 
for i in range(N):
    temp = abs(A -(T - H[i]*0.006))
    if abs(A -(T - H[i]*0.006)) < x:
        x = abs(A -(T - H[i]*0.006))
        ans = i
 
print((ans+1))

# Optimized solution
eval(input())
T,A = list(map(int,input().split()))
a = list(map(int,input().split()))
#最小値
min_val = 100000
min_num=0
for i in range(len(a)):
    d = abs(T-0.006*a[i]-A)
    if d < min_val:
        min_val = d
        min_num = i
print((min_num+1))
# Original solution
import itertools
import math
import fractions
import functools
import copy
n = int(eval(input()))
t, a = list(map(int, input().split()))
h  = list(map(int, input().split()))
minimum = 10**10
index = 0
for i in range(n):
    minimum = min(minimum,abs(a-(t-h[i]*0.006)))
    if minimum == abs(a-(t-h[i]*0.006)):
        index = i

print((index+1))

# Optimized solution
def main():
    n = int(eval(input()))
    t, a = list(map(int, input().split()))
    h = list(map(int, input().split()))
    # s = input()

    mini = 10**10
    ans = 0
    for i, x in enumerate(h):
        c = t - x * 0.006
        if abs(a - c) < mini:
            mini = abs(a - c)
            ans = i+1

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
import sys

n = int(eval(input()))
(t, a) = list(map(int, input().split()))
hs = input().split()

for i in range(len(hs)):
    hs[i] = float(hs[i])

ts = []
for h in hs:
    ts.append(t - h * 0.006)

min = 0
min_t = sys.maxsize
for i in range(len(hs)):
    dt = abs(ts[i] - a)
    if dt < min_t:
        min = i
        min_t = dt
print((min + 1))


# Optimized solution
n = int(eval(input()))
(t, a) = list(map(int, input().split()))
h = list(map(int, input().split()))

min_i = 0
min_t = 10 ** 6
for i, h_i in enumerate(h):
    diff = abs(t - h_i * 0.006 - a)
    if min_t > diff:
        min_i = i
        min_t = diff
print((min_i + 1))
# Original solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
h = list([abs(t-a-x*0.006) for x in list(map(int, input().split()))])
print((h.index(min(h))+1))

# Optimized solution
eval(input())
t, a = list(map(int, input().split()))
hs = list(map(int, input().split()))
arr = []

for h in hs:
    arr.append(abs(t - h * 0.006 - a))
print((arr.index(min(arr))+1))
# Original solution
n,t,a,*h=list(map(int,open(0).read().split()));d,i=9**9,0
for j,v in enumerate(h):
 w=abs(a-t+v*0.006)
 if w<d:d=w;i=j
print((i+1))

# Optimized solution
eval(input());i=lambda:list(map(int,input().split()));t,a=i();h=[abs(t-0.006*x-a)for x in i()];print((h.index(min(h))+1))
# Original solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))
ma = 10 ** 9
ans = 0
for i in range(n):
    if abs(t - h[i] * 0.006 - a) < ma:
        ma = abs(t - h[i] * 0.006 - a)
        ans = i + 1
print(ans)


# Optimized solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))
_abs = 10 ** 9
place = 0
for i in range(n):
    tem = t - h[i] * 0.006
    if _abs > abs(a - tem):
        _abs = abs(a - tem)
        place = i + 1
print(place)
# Original solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))

ans = 0
l = a + 10000

for i in range(n):
    k = abs(t-h[i]*0.006-a)
    if l > k:
        l = k
        ans = i+1

print(ans)

# Optimized solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))

k = []

for i in range(n):
    k.append(abs(t-h[i]*0.006-a))

print((k.index(min(k))+1))
# Original solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
list = [int(i) for i in input().split()]

dif_list = []
answer = 0

for i in range(n):
    t_i = t - list[i] * 0.006
    t_i_dif = abs(a - t_i)
    dif_list.append(t_i_dif)
    if min(dif_list) == t_i_dif:
        answer = i + 1

print(answer)


# Optimized solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
list = [int(i) for i in input().split()]

dif_list = []

for i in range(n):
    t_i = t - list[i] * 0.006
    t_i_dif = abs(a - t_i)
    dif_list.append(t_i_dif)

Min = min(dif_list)
print((dif_list.index(Min) + 1))
# Original solution
n = int(eval(input()))
avg_temparature, kijun_temparature = list(map(int,input().split()))
list_height = [int(i) for i in input().split()]

result_position = 0
for candidate in range(1,len(list_height)):
    a = avg_temparature - (list_height[result_position] * 0.006)
    b = avg_temparature - (list_height[candidate] * 0.006)
    if abs(kijun_temparature - a) > abs(kijun_temparature - b):
        result_position = candidate

print((result_position+1))

# Optimized solution
n = int(eval(input()))
t, a = list(map(int,input().split()))
pList = list(map(int,input().split()))
tList = []
for i in range(n):
  tList.append(abs(a-(t-pList[i]*0.006)))

result = 0
for i in range(1,n):
  if tList[result] > tList[i]:
    result = i

print((result+1))
# Original solution
N = int(eval(input()))
T, A = [int(i) for i in input().split()]
H =[int(i) for i in input().split()]

 
HH=[abs(A-(T-h*0.006))for h in H]  
print((int(HH.index(min(HH))+1)))  

# Optimized solution
N = int(eval(input()))
T, A = list(map(int,input().split()))
H = [int(i) for i in input().split()]

place = [T-i*0.006 for i in H ]
best = [abs(A-place[i]) for i in range(N)]
print((best.index(min(best))+1))
# Original solution
# -*- coding: utf-8 -*-

N = int(eval(input()))
T, A = list(map(int, input().split()))
Hs = list(map(int, input().split()))


def kion_sa(x):
    return abs((T - x * 0.006) - A)


kionsa_list = list()
for i, x in enumerate(Hs):
    kionsa_list.append((kion_sa(x), i))

kionsa_list.sort()
print((kionsa_list[0][1]+1))


# Optimized solution
N = int(eval(input()))
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))

deltas = []
for i in range(N):
    mean_temp = T - H[i]*0.006
    deltas += [abs(mean_temp-A)]

print((deltas.index(min(deltas))+1))
# Original solution
N = int(eval(input()))
T, A = list(map(int,input().split()))
H = list(map(int,input().split()))

tempra = [abs((T - h * 0.006) - A) for h in H]
print((tempra.index(min(tempra)) + 1))

# Optimized solution
N = int(eval(input()))
T, A = list(map(int,input().split()))
H = list(map(int,input().split()))

place_avgtmp = [abs(A - (T - h * 0.006)) for h in H]
print((place_avgtmp.index(min(place_avgtmp)) + 1))
# Original solution
N = int(eval(input()))
T, A = list(map(int,input().split()))
H = list(map(int,input().split()))

place_avgtmp = [abs(A - (T - h * 0.006)) for h in H]
print((place_avgtmp.index(min(place_avgtmp)) + 1))

# Optimized solution
N = int(eval(input()))
T, A = list(map(int,input().split()))
H = list(map(int,input().split()))

tmp = [abs(A - (T - h*0.006)) for h in H]
print((tmp.index(min(tmp))+1))
# Original solution
N = int(eval(input()))
T, A = list(map(int,input().split()))
H = list(map(int,input().split()))
ans = 1e9
for h in H:
  x = abs(T-h*0.006-A)
  if(ans > x):
    tmp = h
    ans = x
print((H.index(tmp)+1))

# Optimized solution
N = int(eval(input()))
T, A = list(map(int,input().split()))
H = list(map(int,input().split()))

res = [abs(T-h*0.006-A) for h in H]
print((res.index(min(res))+1))
# Original solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))
dmin = 10**5
ans = 0
for i in range(n):
    d = abs(a - (t - h[i] * 0.006))
    if d < dmin:
        dmin = d
        ans = i
print((ans + 1))

# Optimized solution
N = int(eval(input()))
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))
HH = [abs(A - (T - x * 0.006)) for x in H]
print((HH.index(min(HH)) + 1))
# Original solution
N = int(eval(input()))
T, A = list(map(int, input().split()))
highs = list(map(int, input().split()))

temps = []
for i in range(N):
    temps.append(abs(A-(T-highs[i]*0.006)))
print((temps.index(min(temps))+1))

# Optimized solution
N = int(eval(input()))
T, A = list(map(int, input().split()))
highs = list(map(int, input().split()))

temps = []
for i in highs:
    diff = abs(A - (T - i*0.006))
    temps.append(diff)
    
print((temps.index(min(temps))+1))
# Original solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
H = [int(i) for i in input().split()]
A = []
for i in range(n):
    x = abs(t - H[i] * 0.006 - a)
    A.append(x)
print((A.index(min(A)) + 1))

# Optimized solution
n = int(eval(input()))
t, a = list(map(int, input().split()))
H = [int(i) for i in input().split()]
B = []
for i in range(n):
    temp = abs(a - (t - H[i] * 0.006))
    B.append(temp)
print((B.index(min(B)) + 1))
# Original solution
from itertools import accumulate
N, K, *A = list(map(int, open(0).read().split()))

def check(d):
    r = sorted([v % d for v in A])
    r_inv = [d - v for v in r]    
    r_cs = [0] + list(accumulate(r))
    r_inv_cs = list(accumulate(r_inv[::-1]))[::-1] + [0]

    ret = False
    for i in range(N + 1):
        flg1 = r_cs[i] <= K
        flg2 = r_cs[i] == r_inv_cs[i]
        ret = (flg1 and flg2) or ret
    
    return ret

M = sum(A)
ans = 0
for i in reversed(list(range(1, int(M ** 0.5) + 1))):
    if M % i == 0 and check(i):
        ans = max(ans, i)
    if M % (M // i) == 0 and check(M // i):
        ans = max(ans, M // i)
        
print(ans)


# Optimized solution
from itertools import accumulate

N, K, *A = list(map(int, open(0).read().split()))

s = sum(A)
divisor = []
for i in range(1, int(s ** 0.5) + 1):
    if s % i == 0:
        divisor.append(i)
        if i != s // i:
            divisor.append(s // i)

ans = 0
for d in divisor:
    x = sorted(v % d for v in A)
    y = [d - r for r in x]
    x_s = [0] + list(accumulate(x))
    y_s = list(accumulate(y[::-1]))[::-1] + [0]

    for i in range(N + 1):
        if x_s[i] <= K and x_s[i] == y_s[i]:
            ans = max(ans, d)
            break

print(ans)
# Original solution
from itertools import accumulate

N, K, *A = list(map(int, open(0).read().split()))

s = sum(A)
divisor = []
for i in range(1, int(s ** 0.5) + 1):
    if s % i == 0:
        divisor.append(i)
        if i != s // i:
            divisor.append(s // i)

ans = 0
for d in divisor:
    x = sorted(v % d for v in A)
    y = [d - r for r in x]
    x_s = [0] + list(accumulate(x))
    y_s = list(accumulate(y[::-1]))[::-1] + [0]

    for i in range(N + 1):
        if x_s[i] <= K and x_s[i] == y_s[i]:
            ans = max(ans, d)
            break

print(ans)


# Optimized solution

"""
https://atcoder.jp/contests/abc136/tasks/abc136_e
"""

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


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


divisor = calc_divisor(sum(X))
ans = 0
for v in divisor:
    cand = sorted(x % v for x in X)
    cs1 = [0] * (N + 1)
    for i in range(N):
        cs1[i + 1] = cs1[i] + cand[i]

    cs2 = [0] * (N + 1)
    for i in reversed(list(range(N))):
        cs2[i] = cs2[i + 1] + v - cand[i]

    for a, b in zip(cs1, cs2):
        if a <= K and a == b:
            ans = max(ans, v)
            break

print(ans)
# Original solution
from itertools import accumulate
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))


A_sum = sum(A)
ans_candidates = []
for n in range(1, int(A_sum ** 0.5) + 1):
    if A_sum % n == 0:
        ans_candidates.append(n)
        ans_candidates.append(A_sum // n)
ans_candidates.sort(reverse=True)


for z in ans_candidates:
    need_add = [(z - a % z) % z for a in A]
    need_add.sort()
    need_minus = [z - na for na in need_add]

    need_add = list(accumulate(need_add))
    need_minus = list(accumulate(need_minus))

    for i in range(N):
        if (need_add[i] == need_minus[-1] - need_minus[i]) and (need_add[i] <= K):
            print(z)
            exit()


# Optimized solution
from itertools import accumulate
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
M = sum(A)


ans_candidates = []
for n in range(1, int(M ** 0.5) + 1):
    if M % n == 0:
        ans_candidates.append(n)
        ans_candidates.append(M // n)


ans = 0
for X in ans_candidates:
    need_plus = sorted([(X - a % X) % X for a in A])
    need_minus = [X - nm for nm in need_plus]

    need_plus = list(accumulate(need_plus))
    need_minus = list(accumulate(need_minus))

    for i in range(N):
        if need_plus[i] > K:
            break

        if need_plus[i] == (need_minus[-1] - need_minus[i]):
            ans = max(ans, X)
            break

print(ans)
# Original solution
from itertools import accumulate
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
M = sum(A)


ans_candidates = []
for n in range(1, int(M ** 0.5) + 1):
    if M % n == 0:
        ans_candidates.append(n)
        ans_candidates.append(M // n)


ans = 0
for X in ans_candidates:
    alpha = sorted([(a % X) for a in A])
    beta = [X - a for a in alpha]

    alpha = list(accumulate(alpha))
    beta = list(accumulate(beta))

    for i in range(N):
        if alpha[i] > K:
            break

        if alpha[i] == (beta[-1] - beta[i]):
            ans = max(ans, X)
            break

print(ans)


# Optimized solution
from itertools import accumulate
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
M = sum(A)

# 答えの候補を列挙
ans_candidates = []
for n in range(1, int(M ** 0.5) + 1):
    if M % n == 0:
        ans_candidates.append(n)
        ans_candidates.append(M // n)


ans = 0
for X in ans_candidates:
    A_mod = sorted([a % X for a in A])
    U = [X - a for a in A_mod]
    D = [-a for a in A_mod]  # わかりやすいので

    U = list(accumulate(U))
    D = list(accumulate(D))

    for i in range(N):
        if -D[i] > K:
            break

        if -D[i] == (U[-1] - U[i]):
            ans = max(ans, X)
            break

print(ans)
# Original solution
import math
def main():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    tot = sum(A)

    cand = helper(tot)
    # print("here", cand)
    for i in cand:
        rems = []
        for j in range(N):
            r = A[j] % i
            if r > 0:
                rems.append(r)
        rems.sort()
        # print(rems)
        tot = sum(rems)
        prefixneg = [0]
        for j in range(len(rems)):
            prefixneg.append(prefixneg[-1] + rems[j])
        # print(prefixneg)
        for j in range(len(rems)+1):
            pos = (len(rems)-j)*i - (tot - prefixneg[j])
            neg = prefixneg[j]
            # print(i, pos, neg)
            if max(pos, neg) <= K:
                return i

    return 1


def helper(n):
    div = set()
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            div.add(i)
            div.add(n//i)
    return sorted(list(div), reverse = True)

if __name__ == '__main__':
    print((main()))

# Optimized solution
import math
def main():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    tot = sum(A)

    cand = helper(tot)
    for i in cand:
        rems = []
        for j in range(N):
            r = A[j] % i
            if r > 0:
                rems.append(r)
        rems.sort()

        tot = sum(rems)
        prefixneg = [0]
        for j in range(len(rems)):
            prefixneg.append(prefixneg[-1] + rems[j])

        for j in range(len(rems)+1):
            pos = (len(rems)-j)*i - (tot - prefixneg[j])
            neg = prefixneg[j]
            if max(pos, neg) <= K:
                return i

    return 1


def helper(n):
    div = set()
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            div.add(i)
            div.add(n//i)
    return sorted(list(div), reverse = True)

if __name__ == '__main__':
    print((main()))
# Original solution
from heapq import heapify, heappush, heappop

def divisor(n):
    divisors = []
    i = 1
    while i * i <= n:
        if n % i == 0:
            divisors.append(i)
            if i != n / i:
                divisors.append(n // i)
        i += 1
    divisors.sort()
    return divisors


N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
divisors = divisor(sum(A))
for d in divisors[::-1]:
    heap = []
    s = 0
    for a in A:
        x = a // d * d - a
        heap.append(x)
        s += -x
    heapify(heap)
    n = 0
    for _ in range(s // d):
        x = heappop(heap)
        if x + d > K:
            break
        else:
            if x + d > 0:
                n += x + d
            heappush(heap, x + d)
    else:
        if sum(abs(x) for x in heap) <= 2 * K:
            print(d)
            exit()


# Optimized solution
def divisor(n):
    divisors = []
    i = 1
    while i * i <= n:
        if n % i == 0:
            divisors.append(i)
            if i * i < n:
                divisors.append(n // i)
        i += 1
    divisors.sort()
    return divisors


N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
divisors = divisor(sum(A))
for d in divisors[::-1]:
    rem = [a % d for a in A]
    rem.sort(reverse=True)
    i = sum(rem) // d
    if sum(rem[i:]) <= K:
        print(d)
        exit()
# Original solution
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
D = sum(A)
D = make_divisors(D)[::-1]

for d in D:
    a = []
    for i in range(N):
        if A[i]%d != 0:
            a.append(A[i]%d)
    a.sort()
    b = [d-x for x in a]
    b.sort()

    c1 = [0]*(len(a)+1)
    for i in range(len(a)):
        c1[i] = a[i]+c1[i-1]
    c2 = [0]*(len(b)+1)
    for i in range(len(b)):
        c2[i] = b[i]+c2[i-1]

    k = float('inf')
    for i in range(len(a)):
        if c1[i] == c2[len(a)-2-i]:
            k = c1[i]
            break
    if k <= K:
        break
print(d)

# Optimized solution
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
D = sum(A)
D = make_divisors(D)[::-1]

for d in D:
    a = []
    for i in range(N):
        a.append(A[i]%d)
    k = 0
    M = max(a)
    while k <= K and M != 0:
        i = 0
        j = 0
        m = d
        M = 0
        for l in range(N):
            if 0 < a[l] < m:
                m = a[l]
                i = l
        for l in range(N-1,-1,-1):
            if a[l] > M:
                M = a[l]
                j = l
        if m == d:
            break
        if m <= d-M:
            a[i] = 0
            a[j] += m
            a[j] %= d
            k += m
        else:
            a[i] -= d-M
            a[i] %= d
            a[j] = 0
            k += d-M
    if k <= K:
        break

print(d)
# Original solution
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)

# Optimized solution
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)