n,k=list(map(int,input().split()))

d=list(map(int,input().split()))



ds = []

 

for i in range(0,n):

    sum = 0

    for j in range(i,n):

        sum += d[j]

        ds.append(sum)



ds.sort(reverse=True)

 

for i in range(40,-1,-1):

    count = 0

    o = []

 

    for dss in ds:

        if dss & (1 << i) > 0 :

            count += 1

            o.append(dss)

    if count >= k :

        ds = list(o)

  

sum = ds[0]

for i in range(1,k):

    sum = sum & ds[i]

 

print(sum)
line = str(eval(input()))

lines = line.split(' ')

 

n = int(lines[0])

k = int(lines[1])

 

d = list()

 

line = str(eval(input()))

lines = line.split(' ')

 

for l in lines:

    d.append(int(l))

 

ds = list()

 

for i in range(0,n):

    sum = 0

    for j in range(i,n):

        sum += d[j]

        ds.append(sum)

 

for i in range(40,-1,-1):

    count = 0

    o = []

 

    for dss in ds:

        if dss & (1 << i) > 0 :

            count += 1

            o.append(dss)

 

    if count >= k :

        ds = list(o)

 

sum = ds[0]

for i in range(1,k):

    sum = sum & ds[i]

 

print(sum)
n, k = list(map(int, input().split()))
d = list(map(int, input().split()))
ds = []
for i in range(0, n):
    sum = 0
    for j in range(i, n):
        sum += d[j]
        ds.append(sum)
ds.sort(reverse=True)
for i in range(40, -1, -1):
    count = 0
    o = []
    for dss in ds:
        if dss & (1 << i) > 0:
            count += 1
            o.append(dss)
    if count >= k:
        ds = list(o)
sum = ds[0]
for i in range(1, k):
    sum = sum & ds[i]
print(sum)

line = str(eval(input()))
lines = line.split(" ")
n = int(lines[0])
k = int(lines[1])
d = list()
line = str(eval(input()))
lines = line.split(" ")
for l in lines:
    d.append(int(l))
ds = list()
for i in range(0, n):
    sum = 0
    for j in range(i, n):
        sum += d[j]
        ds.append(sum)
for i in range(40, -1, -1):
    count = 0
    o = []
    for dss in ds:
        if dss & (1 << i) > 0:
            count += 1
            o.append(dss)
    if count >= k:
        ds = list(o)
sum = ds[0]
for i in range(1, k):
    sum = sum & ds[i]
print(sum)

-n, k = list(map(int, input().split())) -d = list(map(int, input().split())) -ds = [] +line = str(eval(input())) +lines = line.split(" ") +n = int(lines[0]) +k = int(lines[1]) +d = list() +line = str(eval(input())) +lines = line.split(" ") +for l in lines: +    d.append(int(l)) +ds = list() -ds.sort(reverse=True)