def div(n): if n <= 0: return [] S = set() i = 1 while i * i <= n: if n % i == 0: S.add(i) S.add(n // i) i += 1 return list(S) N, K = map(int, input().split()) A = list(map(int, input().split())) ans = 1 S = set() for i in range(N): for d in div(A[i]): S.add(d) def check(d): v = 0 for i in range(N): v += min(A[i]%d, (d - A[i] % d) % d) return v <= K for d in S: if check(d): ans = max(ans, d) print(ans)