N, K = [int(_) for _ in input().split()]

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

B = []

for i in range(N):

    B += [A[i]]

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

        B += [B[-1] + A[j]]



ans = 0

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

    B_new = []

    for b in B:

        if b & 2 ** i:

            B_new += [b]

    if len(B_new) >= K:

        ans += 2 ** i

        B = [_ - 2 ** i for _ in B_new]

    else:

        B = [_ % 2 ** i for _ in B]

print(ans)
import numpy as np

N, K = [int(_) for _ in input().split()]

A = np.array([0] + [int(_) for _ in input().split()])

C = np.cumsum(A)

X = np.zeros(N * (N + 1) // 2, dtype=int)

il = 0

for l in range(N):

    X[il:il + N - l] = C[l + 1:N + 1] - C[l]

    il += N - l

ans = 0

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

    Y = (X // (2**i) & 1)

    I = Y == 1

    if I.sum() >= K:

        X = X[I]

        ans += 2**i

print(ans)

N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
B = []
for i in range(N):
    B += [A[i]]
    for j in range(i + 1, N):
        B += [B[-1] + A[j]]
ans = 0
for i in range(40, -1, -1):
    B_new = []
    for b in B:
        if b & 2**i:
            B_new += [b]
    if len(B_new) >= K:
        ans += 2**i
        B = [_ - 2**i for _ in B_new]
    else:
        B = [_ % 2**i for _ in B]
print(ans)

import numpy as np

N, K = [int(_) for _ in input().split()]
A = np.array([0] + [int(_) for _ in input().split()])
C = np.cumsum(A)
X = np.zeros(N * (N + 1) // 2, dtype=int)
il = 0
for l in range(N):
    X[il : il + N - l] = C[l + 1 : N + 1] - C[l]
    il += N - l
ans = 0
for i in range(40, -1, -1):
    Y = X // (2**i) & 1
    I = Y == 1
    if I.sum() >= K:
        X = X[I]
        ans += 2**i
print(ans)

+import numpy as np + -A = [int(_) for _ in input().split()] -B = [] -for i in range(N): -    B += [A[i]] -    for j in range(i + 1, N): -        B += [B[-1] + A[j]] +A = np.array([0] + [int(_) for _ in input().split()]) +C = np.cumsum(A) +X = np.zeros(N * (N + 1) // 2, dtype=int) +il = 0 +for l in range(N): +    X[il : il + N - l] = C[l + 1 : N + 1] - C[l] +    il += N - l -    B_new = [] -    for b in B: -        if b & 2**i: -            B_new += [b] -    if len(B_new) >= K: +    Y = X // (2**i) & 1 +    I = Y == 1 +    if I.sum() >= K: +        X = X[I] -        B = [_ - 2**i for _ in B_new] -    else: -        B = [_ % 2**i for _ in B]