output_description: Print the maximum possible positive integer that divides every element of A
  after the operations.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      A_1 A_2 \cdots A_{N-1} A_{N}
attempt: import sys
  
  sys.setrecursionlimit(10**7)
  
  
  def LI():
      return [int(x) for x in sys.stdin.readline().split()]
  
  
  def LI_():
      return [int(x) - 1 for x in sys.stdin.readline().split()]
  
  
  def LF():
      return [float(x) for x in sys.stdin.readline().split()]
  
  
  def LS():
      return sys.stdin.readline().split()
  
  
  def II():
      return int(sys.stdin.readline())
  
  
  def SI():
      return sys.stdin.readline().strip()
  
  
  INF = 10**18
  MOD = 10**9 + 7
  
  debug = True
  debug = False
  
  
  def dprint(*objects):
      if debug == True:
          print(*objects)
  
  
  def prime_factors(n):
      i = 2
      factors = []
      while i * i <= n:
          if n % i:
              i += 1
          else:
              n //= i
              factors.append(i)
      if n > 1:
          factors.append(n)
      return factors
  
  
  def main():
      N, K = LI()
      a_list = LI()
      a_list = sorted(a_list)
      total = sum(a_list)
  
      pfactors = prime_factors(total)
      from collections import Counter
  
      c = Counter(pfactors)
      dprint(c)
  
      factor_list = []
      for f, c in c.items():
          k_list = list(range(0, c + 1))
          factor_list.append([f**k for k in k_list])
  
      dprint(factor_list)
      ans_list = []
      from itertools import product
  
      for tup in product(*factor_list):
          ans = 1
          for t in tup:
              ans *= t
          ans_list.append(ans)
  
      ans_list = sorted(ans_list, reverse=True)
      dprint(ans_list)
  
      def check(ans):
          ope = 0
          diff = 0
          for a in a_list:
              if a % ans == 0:
                  continue
              na = a // ans
              near_up = ans * (na + 1)
              near_down = ans * (na)
              dup = abs(a - near_up)
              ddn = abs(a - near_down)
              dope = min(dup, ddn)
              if dup <= ddn:
                  diff += dope
              else:
                  diff -= dope
              ope += dope
              dprint(a, dope, diff)
          ope /= 2
          dprint(ans, ope, diff)
          if ope + abs(diff) % ans <= K:
              return True
          else:
              return False
  
      for ans in ans_list:
          flag = check(ans)
          dprint(ans, flag)
          dprint()
          if flag:
              print(ans)
              return
  
  
  main()
  
problem_description: Statement
  
  We have a sequence of N integers: A_1, A_2, \cdots, A_N.
  
  You can perform the following operation between 0 and K times (inclusive):
  
    * Choose two integers i and j such that i \neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.
  
  Compute the maximum possible positive integer that divides every element of A
  after the operations. Here a positive integer x divides an integer y if and
  only if there exists an integer z such that y = xz.
samples: [{"input": "2 3\n    8 20", "output": "7\n    \n\n7 will divide every element of A if, for example, we perform the following\noperation:\n\n  * Choose i = 2, j = 1. A becomes (7, 21).\n\nWe cannot reach the situation where 8 or greater integer divides every element\nof A.\n\n* * *"}, {"input": "2 10\n    3 5", "output": "8\n    \n\nConsider performing the following five operations:\n\n  * Choose i = 2, j = 1. A becomes (2, 6).\n  * Choose i = 2, j = 1. A becomes (1, 7).\n  * Choose i = 2, j = 1. A becomes (0, 8).\n  * Choose i = 2, j = 1. A becomes (-1, 9).\n  * Choose i = 1, j = 2. A becomes (0, 8).\n\nThen, 0 = 8 \\times 0 and 8 = 8 \\times 1, so 8 divides every element of A. We\ncannot reach the situation where 9 or greater integer divides every element of\nA.\n\n* * *"}, {"input": "4 5\n    10 1 2 22", "output": "7\n    \n\n* * *"}, {"input": "8 7\n    1 7 5 6 8 2 6 5", "output": "5"}]