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 ** 7)



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())



n, k = li()

a = list(li())



cum = [0]

for ai in a:

    cum.append(cum[-1] + ai)



pool = []

for i in range(n+1):

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

        pool.append(cum[j] - cum[i])



MAX_BIT = 41

ans = 0

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

    new_pool = []

    for poli in pool:

        if poli & (1<<bit):

            new_pool.append(poli)



    if len(new_pool) >= k:

        ans += (1<<bit)

        pool = new_pool



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**7)


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())


n, k = li()
a = list(li())
cum = [0]
for ai in a:
    cum.append(cum[-1] + ai)
pool = []
for i in range(n + 1):
    for j in range(i + 1, n + 1):
        pool.append(cum[j] - cum[i])
MAX_BIT = 41
ans = 0
for bit in range(MAX_BIT, -1, -1):
    new_pool = []
    for poli in pool:
        if poli & (1 << bit):
            new_pool.append(poli)
    if len(new_pool) >= k:
        ans += 1 << bit
        pool = new_pool
print(ans)

-sys.setrecursionlimit(10**5) +sys.setrecursionlimit(10**7) -from itertools import accumulate - -acum = list(accumulate([0] + a)) -cand = [] +cum = [0] +for ai in a: +    cum.append(cum[-1] + ai) +pool = [] -        cand.append(acum[j] - acum[i]) +        pool.append(cum[j] - cum[i]) +MAX_BIT = 41 -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 +for bit in range(MAX_BIT, -1, -1): +    new_pool = [] +    for poli in pool: +        if poli & (1 << bit): +            new_pool.append(poli) +    if len(new_pool) >= k: +        ans += 1 << bit +        pool = new_pool