import itertools



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

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

beautiful_num = []



for i in range(N):

    temp = 0

    for n in a[i:]:

        temp += n

        beautiful_num.append("{:040b}".format(temp))



ma_b_cnt = 0

target_set = None



result = 0

for i in range(40):

        for b in beautiful_num:

            if b[i] == "1":

                ma_b_cnt += 1

        if ma_b_cnt >= K:

            result += 2**(40-i-1)

            beautiful_num = [b for b in beautiful_num if b[i] == "1"]

        ma_b_cnt = 0



print(result)
import itertools



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

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

beautiful_num = []



for i in range(N):

    temp = 0

    for n in a[i:]:

        temp += n

        beautiful_num.append(temp)



ma_b_cnt = 0

target_set = None



result = 0

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

        for b in beautiful_num:

            if b & 1 << i != 0:

                ma_b_cnt += 1

        if ma_b_cnt >= K:

            result += 2**i

            beautiful_num = [b for b in beautiful_num if b & 1 << i != 0]

        ma_b_cnt = 0



print(result)
import itertools

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
beautiful_num = []
for i in range(N):
    temp = 0
    for n in a[i:]:
        temp += n
        beautiful_num.append("{:040b}".format(temp))
ma_b_cnt = 0
target_set = None
result = 0
for i in range(40):
    for b in beautiful_num:
        if b[i] == "1":
            ma_b_cnt += 1
    if ma_b_cnt >= K:
        result += 2 ** (40 - i - 1)
        beautiful_num = [b for b in beautiful_num if b[i] == "1"]
    ma_b_cnt = 0
print(result)

import itertools

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
beautiful_num = []
for i in range(N):
    temp = 0
    for n in a[i:]:
        temp += n
        beautiful_num.append(temp)
ma_b_cnt = 0
target_set = None
result = 0
for i in range(40, -1, -1):
    for b in beautiful_num:
        if b & 1 << i != 0:
            ma_b_cnt += 1
    if ma_b_cnt >= K:
        result += 2**i
        beautiful_num = [b for b in beautiful_num if b & 1 << i != 0]
    ma_b_cnt = 0
print(result)

-        beautiful_num.append("{:040b}".format(temp)) +        beautiful_num.append(temp) -for i in range(40): +for i in range(40, -1, -1): -        if b[i] == "1": +        if b & 1 << i != 0: -        result += 2 ** (40 - i - 1) -        beautiful_num = [b for b in beautiful_num if b[i] == "1"] +        result += 2**i +        beautiful_num = [b for b in beautiful_num if b & 1 << i != 0]