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

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

S = [0]

beauties = []

ans = 0



for i in range(N):

    S.append(S[-1]+A[i])



for i in range(N):

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

        beauties.append(S[j]-S[i])



for i in reversed(list(range(64))):

    tmp = []

    for j in range(len(beauties)):

        if (beauties[j]>>i)&1:

            tmp.append(beauties[j])

    if len(tmp)>=K:

        ans += 2**i

        beauties = tmp

        

print(ans)
from itertools import accumulate



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

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



C = [0] + list(accumulate(A))

S = []



for i in range(N):

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

        S.append(C[j] - C[i])



for i in range(64)[::-1]:

    tmp = []

    for s in S:

        if (s >> i) & 1:

            tmp.append(s)



    if len(tmp) >= K:

        S = tmp[:]



res = 2**64 - 1



for i in range(K):

    res &= S[i]



print(res)
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
S = [0]
beauties = []
ans = 0
for i in range(N):
    S.append(S[-1] + A[i])
for i in range(N):
    for j in range(i + 1, N + 1):
        beauties.append(S[j] - S[i])
for i in reversed(list(range(64))):
    tmp = []
    for j in range(len(beauties)):
        if (beauties[j] >> i) & 1:
            tmp.append(beauties[j])
    if len(tmp) >= K:
        ans += 2**i
        beauties = tmp
print(ans)

from itertools import accumulate

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
C = [0] + list(accumulate(A))
S = []
for i in range(N):
    for j in range(i + 1, N + 1):
        S.append(C[j] - C[i])
for i in range(64)[::-1]:
    tmp = []
    for s in S:
        if (s >> i) & 1:
            tmp.append(s)
    if len(tmp) >= K:
        S = tmp[:]
res = 2**64 - 1
for i in range(K):
    res &= S[i]
print(res)

+from itertools import accumulate + -S = [0] -beauties = [] -ans = 0 -for i in range(N): -    S.append(S[-1] + A[i]) +C = [0] + list(accumulate(A)) +S = [] -        beauties.append(S[j] - S[i]) -for i in reversed(list(range(64))): +        S.append(C[j] - C[i]) +for i in range(64)[::-1]: -    for j in range(len(beauties)): -        if (beauties[j] >> i) & 1: -            tmp.append(beauties[j]) +    for s in S: +        if (s >> i) & 1: +            tmp.append(s) -        ans += 2**i -        beauties = tmp -print(ans) +        S = tmp[:] +res = 2**64 - 1 +for i in range(K): +    res &= S[i] +print(res)