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

a=[0]+list(map(int,input().split()))

p=[]

for i in range(n):

	a[i+1]+=a[i]

for i in range(n+1):

	for j in range(i):

		p.append(a[i]-a[j])

p.sort(reverse=True)

ans=0

from math import log,ceil

r=ceil(log(sum(p))+10**-3)

for i in range(r+3,-1,-1):

	cnt=0

	for j in range(len(p)):

		if (ans+2**i)&p[j]==ans+2**i:

			cnt+=1

		if cnt==k:

			break

	if cnt==k:

		ans+=2**i

print(ans)
def main():

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

	a=[0]+list(map(int,input().split()))

	p=[]

	for i in range(n):

		a[i+1]+=a[i]

	for i in range(n+1):

		for j in range(i):

			p.append(a[i]-a[j])

	p.sort()

	ans=0

	from math import log,ceil

	r=ceil(log(sum(p))+10**-3)

	for i in range(r+2,-1,-1):

		cnt=0

		for j in range(len(p)):

			if (ans+2**i)&p[j]==ans+2**i:

				cnt+=1

				if cnt==k:

					break

		if cnt==k:

			ans+=2**i

	print(ans)

if __name__ == '__main__':

	main()
n, k = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
p = []
for i in range(n):
    a[i + 1] += a[i]
for i in range(n + 1):
    for j in range(i):
        p.append(a[i] - a[j])
p.sort(reverse=True)
ans = 0
from math import log, ceil

r = ceil(log(sum(p)) + 10**-3)
for i in range(r + 3, -1, -1):
    cnt = 0
    for j in range(len(p)):
        if (ans + 2**i) & p[j] == ans + 2**i:
            cnt += 1
        if cnt == k:
            break
    if cnt == k:
        ans += 2**i
print(ans)

def main():
    n, k = list(map(int, input().split()))
    a = [0] + list(map(int, input().split()))
    p = []
    for i in range(n):
        a[i + 1] += a[i]
    for i in range(n + 1):
        for j in range(i):
            p.append(a[i] - a[j])
    p.sort()
    ans = 0
    from math import log, ceil

    r = ceil(log(sum(p)) + 10**-3)
    for i in range(r + 2, -1, -1):
        cnt = 0
        for j in range(len(p)):
            if (ans + 2**i) & p[j] == ans + 2**i:
                cnt += 1
                if cnt == k:
                    break
        if cnt == k:
            ans += 2**i
    print(ans)


if __name__ == "__main__":
    main()

-n, k = list(map(int, input().split())) -a = [0] + list(map(int, input().split())) -p = [] -for i in range(n): -    a[i + 1] += a[i] -for i in range(n + 1): -    for j in range(i): -        p.append(a[i] - a[j]) -p.sort(reverse=True) -ans = 0 -from math import log, ceil +def main(): +    n, k = list(map(int, input().split())) +    a = [0] + list(map(int, input().split())) +    p = [] +    for i in range(n): +        a[i + 1] += a[i] +    for i in range(n + 1): +        for j in range(i): +            p.append(a[i] - a[j]) +    p.sort() +    ans = 0 +    from math import log, ceil -r = ceil(log(sum(p)) + 10**-3) -for i in range(r + 3, -1, -1): -    cnt = 0 -    for j in range(len(p)): -        if (ans + 2**i) & p[j] == ans + 2**i: -            cnt += 1 +    r = ceil(log(sum(p)) + 10**-3) +    for i in range(r + 2, -1, -1): +        cnt = 0 +        for j in range(len(p)): +            if (ans + 2**i) & p[j] == ans + 2**i: +                cnt += 1 +                if cnt == k: +                    break -            break -    if cnt == k: -        ans += 2**i -print(ans) +            ans += 2**i +    print(ans) + + +if __name__ == "__main__": +    main()