def cumsum(l):

    c = [0] * len(l)

    for i in range(len(l)):

        c[i] = c[i-1] + l[i]

    return c



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

a = [int(i) for i in input().split()]

c = [0] + cumsum(a)

s = {bin(c[j+i] - c[j]).replace('0b','').zfill(40) for i in range(1, N+1) for j in range(N-i+1)}

ans = 0



for i in range(40):

    t = {j for j in s if j[i] == '1'}

    if len(t) >= K:

        ans += 2**(39-i)

        s = t



print(ans)
def cumsum(l):

    c = [0] * len(l)

    for i in range(len(l)):

        c[i] = c[i-1] + l[i]

    return c



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

a = [int(i) for i in input().split()]

c = [0] + cumsum(a)

s = [bin(c[j+i] - c[j]).replace('0b','').zfill(40) for i in range(1, N+1) for j in range(N-i+1)]

ans = 0



for i in range(40):

    t = [j for j in s if j[i] == '1']

    if len(t) >= K:

        ans += 2**(39-i)

        s = t

print(ans)
def cumsum(l):
    c = [0] * len(l)
    for i in range(len(l)):
        c[i] = c[i - 1] + l[i]
    return c


N, K = list(map(int, input().split()))
a = [int(i) for i in input().split()]
c = [0] + cumsum(a)
s = {
    bin(c[j + i] - c[j]).replace("0b", "").zfill(40)
    for i in range(1, N + 1)
    for j in range(N - i + 1)
}
ans = 0
for i in range(40):
    t = {j for j in s if j[i] == "1"}
    if len(t) >= K:
        ans += 2 ** (39 - i)
        s = t
print(ans)

def cumsum(l):
    c = [0] * len(l)
    for i in range(len(l)):
        c[i] = c[i - 1] + l[i]
    return c


N, K = list(map(int, input().split()))
a = [int(i) for i in input().split()]
c = [0] + cumsum(a)
s = [
    bin(c[j + i] - c[j]).replace("0b", "").zfill(40)
    for i in range(1, N + 1)
    for j in range(N - i + 1)
]
ans = 0
for i in range(40):
    t = [j for j in s if j[i] == "1"]
    if len(t) >= K:
        ans += 2 ** (39 - i)
        s = t
print(ans)

-s = { +s = [ -} +] -    t = {j for j in s if j[i] == "1"} +    t = [j for j in s if j[i] == "1"]