line = str(input())
lines = line.split(' ')

n = int(lines[0])
k = int(lines[1])

d = list()

line = str(input())
lines = line.split(' ')

for l in lines:
    d.append(int(l))

ds = list()

for i in range(0,n):
    for len in range(1,n-i+1):
        sum = 0
        for j in range(i,i+len):
            sum += d[j]
        ds.append(sum)

digit = 0
o = list()

for i in range(40,-1,-1):
    count = 0
    o.clear()

    for dss in ds:
        if dss & (1 << i) > 0 :
            count += 1
            o.append(dss)

    if count >= k :
        ds = o.copy()

    if count == k :
        break

sum = ds[0]
for i in range(1,k):
    sum = sum & ds[i]

print(sum)