import copy

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

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



A_sum = [0]

for a in A:

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



score = []

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

    for l in range(0,r):

        score.append(A_sum[r]-A_sum[l])



ans = 0

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

    count = 0

    score_a = []

    for j in score:

        if (j & (1<<i)):

            count += 1

            score_a.append(j)

    if count >= K:

        ans += (1<<i)

        score = copy.deepcopy(score_a)



print(ans)

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

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



A_sum = [0]

for a in A:

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



score = []

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

    for l in range(0,r):

        score.append(A_sum[r]-A_sum[l])



ans = 0

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

    count = 0

    score_a = []

    for j in score:

        if (j & (1<<i)):

            count += 1

            score_a.append(j)

    if count >= K:

        ans += (1<<i)

        score = [i for i in score_a]



print(ans)

import copy

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A_sum = [0]
for a in A:
    A_sum.append(A_sum[-1] + a)
score = []
for r in range(1, N + 1):
    for l in range(0, r):
        score.append(A_sum[r] - A_sum[l])
ans = 0
for i in range(40, -1, -1):
    count = 0
    score_a = []
    for j in score:
        if j & (1 << i):
            count += 1
            score_a.append(j)
    if count >= K:
        ans += 1 << i
        score = copy.deepcopy(score_a)
print(ans)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A_sum = [0]
for a in A:
    A_sum.append(A_sum[-1] + a)
score = []
for r in range(1, N + 1):
    for l in range(0, r):
        score.append(A_sum[r] - A_sum[l])
ans = 0
for i in range(40, -1, -1):
    count = 0
    score_a = []
    for j in score:
        if j & (1 << i):
            count += 1
            score_a.append(j)
    if count >= K:
        ans += 1 << i
        score = [i for i in score_a]
print(ans)

-import copy - -        score = copy.deepcopy(score_a) +        score = [i for i in score_a]