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

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





cand = []

for i in range(N):

    sum = 0

    for j in range(i, N):

        sum += a[j]

        cand.append(sum)





def countMask(a):

    ret = 0

    for x in cand:

        if (x & a) == a:

            ret += 1

    return ret





ans = 0



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

    if (countMask(ans | (1 << i)) >= K):

        ans |= 1 << i



print(ans)

import bisect

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

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



SA = [0]

for i in range(N):

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



C = []

for i in range(N):

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

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

C.sort()





ans = 0

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

    B = 1 << i

    ind = bisect.bisect_left(C, B)

    if len(C)-ind >= K:

        ans += B

        C = C[ind:]

    for j in range(len(C)):

        C[j] &= B-1

    C.sort()

    # print(i, B, C)

print(ans)

N, K = list(map(int, input().split()))
a = [int(i) for i in input().split()]
cand = []
for i in range(N):
    sum = 0
    for j in range(i, N):
        sum += a[j]
        cand.append(sum)


def countMask(a):
    ret = 0
    for x in cand:
        if (x & a) == a:
            ret += 1
    return ret


ans = 0
for i in range(40, -1, -1):
    if countMask(ans | (1 << i)) >= K:
        ans |= 1 << i
print(ans)

import bisect

N, K = list(map(int, input().split()))
A = [int(i) for i in input().split()]
SA = [0]
for i in range(N):
    SA.append(SA[-1] + A[i])
C = []
for i in range(N):
    for j in range(i + 1, N + 1):
        C.append(SA[j] - SA[i])
C.sort()
ans = 0
for i in range(41, -1, -1):
    B = 1 << i
    ind = bisect.bisect_left(C, B)
    if len(C) - ind >= K:
        ans += B
        C = C[ind:]
    for j in range(len(C)):
        C[j] &= B - 1
    C.sort()
    # print(i, B, C)
print(ans)

+import bisect + -a = [int(i) for i in input().split()] -cand = [] +A = [int(i) for i in input().split()] +SA = [0] -    sum = 0 -    for j in range(i, N): -        sum += a[j] -        cand.append(sum) - - -def countMask(a): -    ret = 0 -    for x in cand: -        if (x & a) == a: -            ret += 1 -    return ret - - +    SA.append(SA[-1] + A[i]) +C = [] +for i in range(N): +    for j in range(i + 1, N + 1): +        C.append(SA[j] - SA[i]) +C.sort() -for i in range(40, -1, -1): -    if countMask(ans | (1 << i)) >= K: -        ans |= 1 << i +for i in range(41, -1, -1): +    B = 1 << i +    ind = bisect.bisect_left(C, B) +    if len(C) - ind >= K: +        ans += B +        C = C[ind:] +    for j in range(len(C)): +        C[j] &= B - 1 +    C.sort() +    # print(i, B, C)