import sys,queue,math,copy,itertools,bisect,collections,heapq

sys.setrecursionlimit(10**7)

INF = 10**18

MOD = 10**9 + 7

LI = lambda : [int(x) for x in sys.stdin.readline().split()]

_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]

NI = lambda : int(sys.stdin.readline())



N,K = LI()

A = LI()



sa = list(itertools.accumulate([0]+A))

b = []

for i in range(N):

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

        b.append(sa[j]-sa[i])

b.sort(reverse=True)

max_b = (max(b)).bit_length()



mask = 0

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

    bit = 2**i

    cnt = 0

    for x in b:

        if x & mask == mask:

            cnt += (x & bit > 0)

    if cnt >= K:

        mask += bit



print (mask)





import sys,queue,math,copy,itertools,bisect,collections,heapq

LI = lambda : [int(x) for x in sys.stdin.readline().split()]



N,K = LI()

A = LI()



sa = list(itertools.accumulate([0]+A))

b = []

for i in range(N):

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

        b.append(sa[j]-sa[i])

#b.sort(reverse=True)

max_b = max(b).bit_length()



mask = 0

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

    bit = 2**i

    cnt = 0

    for x in b:

        if x & mask == mask:

            cnt += (x & bit > 0)

    if cnt >= K:

        mask += bit

print (mask)
import sys, queue, math, copy, itertools, bisect, collections, heapq

sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda: [int(x) for x in sys.stdin.readline().split()]
_LI = lambda: [int(x) - 1 for x in sys.stdin.readline().split()]
NI = lambda: int(sys.stdin.readline())
N, K = LI()
A = LI()
sa = list(itertools.accumulate([0] + A))
b = []
for i in range(N):
    for j in range(i + 1, N + 1):
        b.append(sa[j] - sa[i])
b.sort(reverse=True)
max_b = (max(b)).bit_length()
mask = 0
for i in range(max_b - 1, -1, -1):
    bit = 2**i
    cnt = 0
    for x in b:
        if x & mask == mask:
            cnt += x & bit > 0
    if cnt >= K:
        mask += bit
print(mask)

import sys, queue, math, copy, itertools, bisect, collections, heapq

LI = lambda: [int(x) for x in sys.stdin.readline().split()]
N, K = LI()
A = LI()
sa = list(itertools.accumulate([0] + A))
b = []
for i in range(N):
    for j in range(i + 1, N + 1):
        b.append(sa[j] - sa[i])
# b.sort(reverse=True)
max_b = max(b).bit_length()
mask = 0
for i in range(max_b - 1, -1, -1):
    bit = 2**i
    cnt = 0
    for x in b:
        if x & mask == mask:
            cnt += x & bit > 0
    if cnt >= K:
        mask += bit
print(mask)

-sys.setrecursionlimit(10**7) -INF = 10**18 -MOD = 10**9 + 7 -_LI = lambda: [int(x) - 1 for x in sys.stdin.readline().split()] -NI = lambda: int(sys.stdin.readline()) -b.sort(reverse=True) -max_b = (max(b)).bit_length() +# b.sort(reverse=True) +max_b = max(b).bit_length()