import sys

stdin = sys.stdin



sys.setrecursionlimit(10**5)



def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



from itertools import accumulate



n,k = li()

a = list(li())



a_cum = [0] + list(accumulate(a))

sm_lst = []

for i in range(n+1):

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

        sm_lst.append(a_cum[j] - a_cum[i])

        

pop = sm_lst

ans = 0

for bit in range(40,-1,-1):

    yes=[]

    no=[]

    

    for s in pop:

        if s & (1<<bit):

            yes.append(s)

        else:

            no.append(s)

            

    if len(yes) >= k:

        ans += (1<<bit)

        pop = yes

        



print(ans)

    
import sys

stdin = sys.stdin

 

sys.setrecursionlimit(10**5) 

 

def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



from itertools import accumulate



n,k = li()

a = list(li())



acum = list(accumulate([0]+a))



cand = []

for i in range(n+1):

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

        cand.append(acum[j] - acum[i])



ans = 0



for mask in range(40, -1, -1):

    satis = sum([bool(ci&(1<<mask)) for ci in cand])



    if satis >= k:

        ans += (1<<mask)

        nex = [ci for ci in cand if ci & (1<<mask)]

        cand = nex

        



print(ans)
import sys

stdin = sys.stdin
sys.setrecursionlimit(10**5)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


from itertools import accumulate

n, k = li()
a = list(li())
a_cum = [0] + list(accumulate(a))
sm_lst = []
for i in range(n + 1):
    for j in range(i + 1, n + 1):
        sm_lst.append(a_cum[j] - a_cum[i])
pop = sm_lst
ans = 0
for bit in range(40, -1, -1):
    yes = []
    no = []
    for s in pop:
        if s & (1 << bit):
            yes.append(s)
        else:
            no.append(s)
    if len(yes) >= k:
        ans += 1 << bit
        pop = yes
print(ans)

import sys

stdin = sys.stdin
sys.setrecursionlimit(10**5)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


from itertools import accumulate

n, k = li()
a = list(li())
acum = list(accumulate([0] + a))
cand = []
for i in range(n + 1):
    for j in range(i + 1, n + 1):
        cand.append(acum[j] - acum[i])
ans = 0
for mask in range(40, -1, -1):
    satis = sum([bool(ci & (1 << mask)) for ci in cand])
    if satis >= k:
        ans += 1 << mask
        nex = [ci for ci in cand if ci & (1 << mask)]
        cand = nex
print(ans)

-a_cum = [0] + list(accumulate(a)) -sm_lst = [] +acum = list(accumulate([0] + a)) +cand = [] -        sm_lst.append(a_cum[j] - a_cum[i]) -pop = sm_lst +        cand.append(acum[j] - acum[i]) -for bit in range(40, -1, -1): -    yes = [] -    no = [] -    for s in pop: -        if s & (1 << bit): -            yes.append(s) -        else: -            no.append(s) -    if len(yes) >= k: -        ans += 1 << bit -        pop = yes +for mask in range(40, -1, -1): +    satis = sum([bool(ci & (1 << mask)) for ci in cand]) +    if satis >= k: +        ans += 1 << mask +        nex = [ci for ci in cand if ci & (1 << mask)] +        cand = nex