output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      a_1 a_2 ... a_N
attempt: a = input().split()
  a = [int(i) for i in a]
  b = input().split()
  b = [int(i) for i in b]
  
  
  def cao(aller, i):
      dicter = dict()
      for m in aller:
          for n in m:
              if n < i:
                  try:
                      dicter[n].append(m)
                  except:
                      dicter[n] = [m]
      for i in sorted(dicter)[::-1]:
          if len(dicter[i]) >= a[1]:
              return dicter[i], i
      return [], -1
  
  
  aller = [0]
  sumer = 0
  for i in b:
      sumer += i
      aller.append(sumer)
  
  superlist = dict()
  for i in range(len(b)):
      for j in range(i + 1, len(b) + 1):
          temp = bin(aller[j] - aller[i])[::-1]
          x = []
          for k in range(len(temp)):
              if temp[k] == "1":
                  x.append(k)
          for m in x:
              try:
                  superlist[m].append(x)
              except:
                  superlist[m] = [x]
  
  for i in sorted(superlist)[::-1]:
      if len(superlist[i]) >= a[1]:
          li = superlist[i]
          sumer = 2**i
          gan1, gan2 = cao(li, i)
          while gan2 != -1:
              sumer += 2**gan2
              gan1, gan2 = cao(gan1, gan2)
          print(sumer)
          break
  
problem_description: Statement
  
  One day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer
  sequence (a_1, ..., a_N) of length N. He is interested in properties of the
  sequence a.
  
  For a nonempty contiguous subsequence a_l, ..., a_r (1 \leq l \leq r \leq N)
  of the sequence a, its _beauty_ is defined as a_l + ... + a_r. Niwango-kun
  wants to know the maximum possible value of the bitwise AND of the beauties of
  K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous
  subsequences. (Subsequences may share elements.)
  
  Find the maximum possible value for him.
samples: [{"input": "4 2\n    2 5 2 5", "output": "12\n    \n\nThere are 10 nonempty contiguous subsequences of a. Let us enumerate them:\n\n  * contiguous subsequences starting from the first element: \\\\{2\\\\}, \\\\{2, 5\\\\}, \\\\{2, 5, 2\\\\}, \\\\{2, 5, 2, 5\\\\}\n  * contiguous subsequences starting from the second element: \\\\{5\\\\}, \\\\{5, 2\\\\}, \\\\{5, 2, 5\\\\}\n  * contiguous subsequences starting from the third element: \\\\{2\\\\}, \\\\{2, 5\\\\}\n  * contiguous subsequences starting from the fourth element: \\\\{5\\\\}\n\n(Note that even if the elements of subsequences are equal, subsequences that\nhave different starting indices are considered to be different.)\n\nThe maximum possible bitwise AND of the beauties of two different contiguous\nsubsequences is 12. This can be achieved by choosing \\\\{5, 2, 5\\\\} (with\nbeauty 12) and \\\\{2, 5, 2, 5\\\\} (with beauty 14).\n\n* * *"}, {"input": "8 4\n    9 1 8 2 7 5 6 4", "output": "32"}]