ma = lambda :map(int,input().split())

lma = lambda :list(map(int,input().split()))

tma = lambda :tuple(map(int,input().split()))

ni = lambda:int(input())

yn = lambda fl:print("Yes") if fl else print("No")

import collections

import math

import itertools

import heapq as hq



n,k = ma()

A = lma()

bu = []

for i in range(n):

    tmp=0

    for j in range(i,n):

        tmp+=A[j]

        bu.append(tmp)

mb = bin(max(bu))

ls = [0]*(len(mb)-2)

for b in bu:

    for i in range(len(bin(b))-2):

        if (b>>i &1):

            ls[i]+=1

ans = 0

tmp=bu

for i in range(len(mb)-3,-1,-1):

    if ls[i]<k:

        continue

    tmp2=[]

    for b in tmp:

        if (b>>i &1):

            tmp2.append(b)

    if len(tmp2)>=k:

        ans+=2**i

        tmp=tmp2

    else:

        pass

print(ans)

ma = lambda :list(map(int,input().split()))

lma = lambda :list(map(int,input().split()))



n,k = ma()

A = lma()

bu = []

for i in range(n):

    tmp=0

    for j in range(i,n):

        tmp+=A[j]

        bu.append(tmp)

mb = bin(max(bu))

ans = 0

for i in range(len(mb)-3,-1,-1):

    tmp=[]

    for b in bu:

        if (b>>i &1):

            tmp.append(b)

    if len(tmp)>=k:

        ans+=2**i

        bu=tmp

    else:

        pass

print(ans)

ma = lambda: map(int, input().split())
lma = lambda: list(map(int, input().split()))
tma = lambda: tuple(map(int, input().split()))
ni = lambda: int(input())
yn = lambda fl: print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

n, k = ma()
A = lma()
bu = []
for i in range(n):
    tmp = 0
    for j in range(i, n):
        tmp += A[j]
        bu.append(tmp)
mb = bin(max(bu))
ls = [0] * (len(mb) - 2)
for b in bu:
    for i in range(len(bin(b)) - 2):
        if b >> i & 1:
            ls[i] += 1
ans = 0
tmp = bu
for i in range(len(mb) - 3, -1, -1):
    if ls[i] < k:
        continue
    tmp2 = []
    for b in tmp:
        if b >> i & 1:
            tmp2.append(b)
    if len(tmp2) >= k:
        ans += 2**i
        tmp = tmp2
    else:
        pass
print(ans)

ma = lambda: list(map(int, input().split()))
lma = lambda: list(map(int, input().split()))
n, k = ma()
A = lma()
bu = []
for i in range(n):
    tmp = 0
    for j in range(i, n):
        tmp += A[j]
        bu.append(tmp)
mb = bin(max(bu))
ans = 0
for i in range(len(mb) - 3, -1, -1):
    tmp = []
    for b in bu:
        if b >> i & 1:
            tmp.append(b)
    if len(tmp) >= k:
        ans += 2**i
        bu = tmp
    else:
        pass
print(ans)

-ma = lambda: map(int, input().split()) +ma = lambda: list(map(int, input().split())) -tma = lambda: tuple(map(int, input().split())) -ni = lambda: int(input()) -yn = lambda fl: print("Yes") if fl else print("No") -import collections -import math -import itertools -import heapq as hq - -ls = [0] * (len(mb) - 2) -for b in bu: -    for i in range(len(bin(b)) - 2): +ans = 0 +for i in range(len(mb) - 3, -1, -1): +    tmp = [] +    for b in bu: -            ls[i] += 1 -ans = 0 -tmp = bu -for i in range(len(mb) - 3, -1, -1): -    if ls[i] < k: -        continue -    tmp2 = [] -    for b in tmp: -        if b >> i & 1: -            tmp2.append(b) -    if len(tmp2) >= k: +            tmp.append(b) +    if len(tmp) >= k: -        tmp = tmp2 +        bu = tmp