import itertools

n,k = list(map(int,input().split()))

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

b = [a[0]]

for i in range(n-1):

    b.append(b[i]+a[i+1])

c = list(itertools.combinations(list(range(n)),2))

s = a

for i in c:

    s.append(b[i[1]]-b[i[0]]+a[i[0]])

s.sort(reverse=True)

l = len(bin(s[0]))-2

d = 1<<l-1

t = 0

while d>0:

    s1 = []

    if s[k-1] >= d:

        t += d

        for i in s:

            if i >= d:

                s1.append(i)

            else:

                s=s1

                break

    for i in range(len(s)):

        if s[i] >= d:

            s[i] -= d

        else:

            s.sort(reverse=True)

            break

    d //= 2

print(t)
n,k = list(map(int,input().split()))

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

b = [a[0]]

for i in range(n-1):

    b.append(b[i]+a[i+1])

s = b

for i in range(n-1):

    for j in range(i,n-1):

        s.append(b[j+1]-b[i])

s.sort(reverse=True)

l = len(bin(s[0]))-2

d = 1<<l-1

t = 0

while d>0:

    s1 = []

    if s[k-1] >= d:

        t += d

        for i in s:

            if i >= d:

                s1.append(i)

            else:

                s=s1

                break

    for i in range(len(s)):

        if s[i] >= d:

            s[i] -= d

        else:

            s.sort(reverse=True)

            break

    d //= 2

print(t)
import itertools

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [a[0]]
for i in range(n - 1):
    b.append(b[i] + a[i + 1])
c = list(itertools.combinations(list(range(n)), 2))
s = a
for i in c:
    s.append(b[i[1]] - b[i[0]] + a[i[0]])
s.sort(reverse=True)
l = len(bin(s[0])) - 2
d = 1 << l - 1
t = 0
while d > 0:
    s1 = []
    if s[k - 1] >= d:
        t += d
        for i in s:
            if i >= d:
                s1.append(i)
            else:
                s = s1
                break
    for i in range(len(s)):
        if s[i] >= d:
            s[i] -= d
        else:
            s.sort(reverse=True)
            break
    d //= 2
print(t)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [a[0]]
for i in range(n - 1):
    b.append(b[i] + a[i + 1])
s = b
for i in range(n - 1):
    for j in range(i, n - 1):
        s.append(b[j + 1] - b[i])
s.sort(reverse=True)
l = len(bin(s[0])) - 2
d = 1 << l - 1
t = 0
while d > 0:
    s1 = []
    if s[k - 1] >= d:
        t += d
        for i in s:
            if i >= d:
                s1.append(i)
            else:
                s = s1
                break
    for i in range(len(s)):
        if s[i] >= d:
            s[i] -= d
        else:
            s.sort(reverse=True)
            break
    d //= 2
print(t)

-import itertools - -c = list(itertools.combinations(list(range(n)), 2)) -s = a -for i in c: -    s.append(b[i[1]] - b[i[0]] + a[i[0]]) +s = b +for i in range(n - 1): +    for j in range(i, n - 1): +        s.append(b[j + 1] - b[i])