import sys input = sys.stdin.readline N,K=map(int,input().split()) A=list(map(int,input().split())) def fact(x): xr=round(x**(1/2))+1 LIST=[] for i in range(1,xr+1): if x%i==0: LIST.append(i) LIST.append(x//i) return set(LIST) from functools import lru_cache @lru_cache(maxsize=None) def calc(x): score=0 for i in range(N): score+=min((x-A[i])%x,(A[i]-x)%x) if score<=K: return True else: return False MAX=max(A) ANS=0 for i in range(MAX-K,MAX+K+1): if i<=0: continue for f in fact(i): if calc(f)==True: ANS=max(ANS,f) print(ANS)