# -*- coding: utf-8 -*-

def inpl(): return list(map(int, input().split()))



N, K = inpl()

A = inpl()

tmp = 0

S = [0]*N

Q = []

for i in range(N):

    tmp += A[i]

    S[i] = tmp

    Q.append(tmp)



tmp = 0

for i in range(1, N):

    tmp = S[i-1]

    for j in range(i, N):

        #print(i, j)

        v = S[j] -S[i-1]

        Q.append(v)



res = 0

while True:

    ok = 0

    for i in range(40):

        num = res + int("1" + "0"*i, 2)

        tmp = 0

        for j in range(len(Q)):

            if num & Q[j] == num:

                tmp += 1

        if tmp >= K:

            ok = num

    if res < ok:

        res = ok

    else:

        break

print(res)
# -*- coding: utf-8 -*-

def inpl(): return list(map(int, input().split()))



N, K = inpl()

A = inpl()

tmp = 0

S = [0]*N

Q = []

for i in range(N):

    tmp += A[i]

    S[i] = tmp

    Q.append(tmp)



tmp = 0

for i in range(1, N):

    tmp = S[i-1]

    for j in range(i, N):

        #print(i, j)

        v = S[j] -S[i-1]

        Q.append(v)



res = 0

L = len(Q)

I = len(bin(sum(A))) - 2

while True:

    ok = 0

    for i in range(I):

        num = res + 2**i

        tmp = 0

        for j in range(L):

            if num & Q[j] == num:

                tmp += 1

        if tmp >= K:

            ok = num



    I = len(bin(res - ok)) - 2

    if res < ok & ok > 0:

        res = ok

    else:

        break



print(res)
# -*- coding: utf-8 -*-
def inpl():
    return list(map(int, input().split()))


N, K = inpl()
A = inpl()
tmp = 0
S = [0] * N
Q = []
for i in range(N):
    tmp += A[i]
    S[i] = tmp
    Q.append(tmp)
tmp = 0
for i in range(1, N):
    tmp = S[i - 1]
    for j in range(i, N):
        # print(i, j)
        v = S[j] - S[i - 1]
        Q.append(v)
res = 0
while True:
    ok = 0
    for i in range(40):
        num = res + int("1" + "0" * i, 2)
        tmp = 0
        for j in range(len(Q)):
            if num & Q[j] == num:
                tmp += 1
        if tmp >= K:
            ok = num
    if res < ok:
        res = ok
    else:
        break
print(res)

# -*- coding: utf-8 -*-
def inpl():
    return list(map(int, input().split()))


N, K = inpl()
A = inpl()
tmp = 0
S = [0] * N
Q = []
for i in range(N):
    tmp += A[i]
    S[i] = tmp
    Q.append(tmp)
tmp = 0
for i in range(1, N):
    tmp = S[i - 1]
    for j in range(i, N):
        # print(i, j)
        v = S[j] - S[i - 1]
        Q.append(v)
res = 0
L = len(Q)
I = len(bin(sum(A))) - 2
while True:
    ok = 0
    for i in range(I):
        num = res + 2**i
        tmp = 0
        for j in range(L):
            if num & Q[j] == num:
                tmp += 1
        if tmp >= K:
            ok = num
    I = len(bin(res - ok)) - 2
    if res < ok & ok > 0:
        res = ok
    else:
        break
print(res)

+L = len(Q) +I = len(bin(sum(A))) - 2 -    for i in range(40): -        num = res + int("1" + "0" * i, 2) +    for i in range(I): +        num = res + 2**i -        for j in range(len(Q)): +        for j in range(L): -    if res < ok: +    I = len(bin(res - ok)) - 2 +    if res < ok & ok > 0: