N,K = map(int,input().split()) A = list(map(int,input().split())) divs = set() for a in A: m = 1 while m*m <= a: if N%m==0: divs.add(m) divs.add(a//m) m += 1 cands = set() for d in divs: for i in range(-K,K+1): if d+i > 0: cands.add(d+i) for g in sorted(cands, reverse=True): cnt = 0 for a in A: tmp = -a%g if a > g: tmp = min(tmp, a%g) cnt += tmp if cnt > K: break else: exit(print(g))