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

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



accum = [0] * N

for i in range(N):

    if i == 0:

        accum[i] = A[i]

    else:

        accum[i] = accum[i-1] + A[i]







B = []

for l in range(N):

    for r in range(l, N):

        if l == 0:

            B.append(accum[r])

        else:

            B.append(accum[r] - accum[l-1])









ans = 0

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

    

    cnt = 0

    nxt_B = []

    for b in B:

        if b & (1 << i):

            cnt += 1

            nxt_B.append(b)



    if cnt >= K:

        ans += 2**i

        B = nxt_B



print(ans)






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

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



accum = [0] * N

accum[0] = A[0]

for i in  range(1,N):

    accum[i] = accum[i-1] + A[i]



B = []

for l in range(N):

    for r in range(l,N):

        if l == 0:

            B.append(accum[r])

        else:

            B.append(accum[r] - accum[l-1])





ans = 0

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

    used = []

    cnt = 0

    for b in B:

        if b & (1 << i):

            cnt += 1

            used.append(b)



    if cnt >= K:

        ans += pow(2,i)

        B = used





print(ans)
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
accum = [0] * N
for i in range(N):
    if i == 0:
        accum[i] = A[i]
    else:
        accum[i] = accum[i - 1] + A[i]
B = []
for l in range(N):
    for r in range(l, N):
        if l == 0:
            B.append(accum[r])
        else:
            B.append(accum[r] - accum[l - 1])
ans = 0
for i in range(50, -1, -1):
    cnt = 0
    nxt_B = []
    for b in B:
        if b & (1 << i):
            cnt += 1
            nxt_B.append(b)
    if cnt >= K:
        ans += 2**i
        B = nxt_B
print(ans)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
accum = [0] * N
accum[0] = A[0]
for i in range(1, N):
    accum[i] = accum[i - 1] + A[i]
B = []
for l in range(N):
    for r in range(l, N):
        if l == 0:
            B.append(accum[r])
        else:
            B.append(accum[r] - accum[l - 1])
ans = 0
for i in range(45, -1, -1):
    used = []
    cnt = 0
    for b in B:
        if b & (1 << i):
            cnt += 1
            used.append(b)
    if cnt >= K:
        ans += pow(2, i)
        B = used
print(ans)

-for i in range(N): -    if i == 0: -        accum[i] = A[i] -    else: -        accum[i] = accum[i - 1] + A[i] +accum[0] = A[0] +for i in range(1, N): +    accum[i] = accum[i - 1] + A[i] -for i in range(50, -1, -1): +for i in range(45, -1, -1): +    used = [] -    nxt_B = [] -            nxt_B.append(b) +            used.append(b) -        ans += 2**i -        B = nxt_B +        ans += pow(2, i) +        B = used