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

    d2 = d-1        

    for i in range(len(s)):

        if s[i] > d2:

            s[i] = s[i]&d2

        else:

            s.sort(reverse=True)

            break

    d = d>>1

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

    if len(s) < k:

        break

    for i in range(len(s)):

        if s[i] >= d:

            s[i] -= d

        else:

            s.sort(reverse=True)

            break

    if len(s) == k:

        t2 = d-1

        for i in s:

            t2 = t2&i

        t = t|t2

        break

    d = d>>1

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
    d2 = d - 1
    for i in range(len(s)):
        if s[i] > d2:
            s[i] = s[i] & d2
        else:
            s.sort(reverse=True)
            break
    d = d >> 1
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
    if len(s) < k:
        break
    for i in range(len(s)):
        if s[i] >= d:
            s[i] -= d
        else:
            s.sort(reverse=True)
            break
    if len(s) == k:
        t2 = d - 1
        for i in s:
            t2 = t2 & i
        t = t | t2
        break
    d = d >> 1
print(t)

-    d2 = d - 1 +    if len(s) < k: +        break -        if s[i] > d2: -            s[i] = s[i] & d2 +        if s[i] >= d: +            s[i] -= d +    if len(s) == k: +        t2 = d - 1 +        for i in s: +            t2 = t2 & i +        t = t | t2 +        break