import copy
N,K=list(map(int,input().split()))
a=list(map(int,input().split()))

num=0
a_sum=[0]
for i in range(N):
  num+=a[i]
  a_sum.append(num)
  

a_mat=[[0 for i in range(N)] for j in range(N)]
non_zero=[]
for i in range(N):
  for j in range(i,N):
    a_mat[i][j] = a_sum[j+1]-a_sum[i]
    non_zero.append([i,j])

a_mat2=copy.deepcopy(a_mat)

maxbit=1
while True:
  if a_sum[N]<2**maxbit and a_sum[N]>=2**(maxbit-1): 
    break
  else:
    maxbit+=1
maxnum=0
num_rest=int(N*(N+1)/2)
num_rest_now=int(N*(N+1)/2)
for bit in range(maxbit):
  non_zero2=[]
  for i, j in non_zero:
    if a_mat[i][j]&(2**(maxbit-bit-1)) == 0 and a_mat[i][j]!=0:
      num_rest_now-=1
      a_mat2[i][j]=0
    else:
      non_zero2.append([i,j])
  #print(non_zero)
  #print(a_mat)
  #print(num_rest_now)
  
  if num_rest_now >= K:
    maxnum+=2**(maxbit-bit-1)
    a_mat=copy.deepcopy(a_mat2)
    num_rest=num_rest_now
    non_zero=copy.deepcopy(non_zero2)
  else:
    a_mat2=copy.deepcopy(a_mat)
    num_rest_now=num_rest
    
  
  
print(maxnum)
    