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

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

cums = [0]

for a in A:

    cums.append(cums[-1] + a)



vs = []

for l in range(N):

    for r in range(l+1,N+1):

        vs.append(cums[r] - cums[l])

vs.sort(reverse=True)



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

    tmps = []

    for v in vs:

        if v&(1<<i):

            tmps.append(v)

    if len(tmps) >= K:

        vs = tmps



if len(vs) < K:

    print((0))

else:

    ans = vs[0]

    for v in vs[1:K]:

        ans &= v

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

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

B = []

for i,a in enumerate(A):

    k = 0

    for c in A[i:]:

        k += c

        B.append(k)



ans = 0

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

    C = []

    for b in B:

        if b&(1<<i):

            C.append(b)

    if len(C) >= K:

        B = C

        ans += 2**i

print(ans)
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
cums = [0]
for a in A:
    cums.append(cums[-1] + a)
vs = []
for l in range(N):
    for r in range(l + 1, N + 1):
        vs.append(cums[r] - cums[l])
vs.sort(reverse=True)
for i in range(100, -1, -1):
    tmps = []
    for v in vs:
        if v & (1 << i):
            tmps.append(v)
    if len(tmps) >= K:
        vs = tmps
if len(vs) < K:
    print((0))
else:
    ans = vs[0]
    for v in vs[1:K]:
        ans &= v
    print(ans)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = []
for i, a in enumerate(A):
    k = 0
    for c in A[i:]:
        k += c
        B.append(k)
ans = 0
for i in range(40, -1, -1):
    C = []
    for b in B:
        if b & (1 << i):
            C.append(b)
    if len(C) >= K:
        B = C
        ans += 2**i
print(ans)

-cums = [0] -for a in A: -    cums.append(cums[-1] + a) -vs = [] -for l in range(N): -    for r in range(l + 1, N + 1): -        vs.append(cums[r] - cums[l]) -vs.sort(reverse=True) -for i in range(100, -1, -1): -    tmps = [] -    for v in vs: -        if v & (1 << i): -            tmps.append(v) -    if len(tmps) >= K: -        vs = tmps -if len(vs) < K: -    print((0)) -else: -    ans = vs[0] -    for v in vs[1:K]: -        ans &= v -    print(ans) +B = [] +for i, a in enumerate(A): +    k = 0 +    for c in A[i:]: +        k += c +        B.append(k) +ans = 0 +for i in range(40, -1, -1): +    C = [] +    for b in B: +        if b & (1 << i): +            C.append(b) +    if len(C) >= K: +        B = C +        ans += 2**i +print(ans)