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

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



cumA = [0] * (N + 1)

for i in range(1, N + 1):

    cumA[i] = cumA[i - 1] + A[i - 1]



beauty = []

for left in range(N):

    for right in range(left + 1, N + 1):

        b = cumA[right] - cumA[left]

        beauty.append(b)



ans = 0

M = max(beauty).bit_length()



for digit in range(M)[:: -1]:

    new = ans + (1 << digit)

    cnt = 0

    for b in beauty:

        if b & new == new:

            cnt += 1

    if cnt >= K:

        ans = new



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

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



S = []

for i in range(N):

    s = 0

    for a in A[i:]:

        s += a

        S.append(s)



def isOk(n):

    return sum([n & a == n for a in S]) >= K



ans = 0

for d in range(40)[:: -1]:

    if isOk(ans | (1 << d)):

        ans |= (1 << d)

print(ans)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
cumA = [0] * (N + 1)
for i in range(1, N + 1):
    cumA[i] = cumA[i - 1] + A[i - 1]
beauty = []
for left in range(N):
    for right in range(left + 1, N + 1):
        b = cumA[right] - cumA[left]
        beauty.append(b)
ans = 0
M = max(beauty).bit_length()
for digit in range(M)[::-1]:
    new = ans + (1 << digit)
    cnt = 0
    for b in beauty:
        if b & new == new:
            cnt += 1
    if cnt >= K:
        ans = new
print(ans)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
S = []
for i in range(N):
    s = 0
    for a in A[i:]:
        s += a
        S.append(s)


def isOk(n):
    return sum([n & a == n for a in S]) >= K


ans = 0
for d in range(40)[::-1]:
    if isOk(ans | (1 << d)):
        ans |= 1 << d
print(ans)

-cumA = [0] * (N + 1) -for i in range(1, N + 1): -    cumA[i] = cumA[i - 1] + A[i - 1] -beauty = [] -for left in range(N): -    for right in range(left + 1, N + 1): -        b = cumA[right] - cumA[left] -        beauty.append(b) +S = [] +for i in range(N): +    s = 0 +    for a in A[i:]: +        s += a +        S.append(s) + + +def isOk(n): +    return sum([n & a == n for a in S]) >= K + + -M = max(beauty).bit_length() -for digit in range(M)[::-1]: -    new = ans + (1 << digit) -    cnt = 0 -    for b in beauty: -        if b & new == new: -            cnt += 1 -    if cnt >= K: -        ans = new +for d in range(40)[::-1]: +    if isOk(ans | (1 << d)): +        ans |= 1 << d