import sys

import numpy as np

import itertools



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N, K = lr()

A = np.array([0] + lr())

A_cum = A.cumsum().tolist()

beauties = []

for i, j in itertools.combinations(list(range(N+1)), 2):

    beauties.append(A_cum[j] - A_cum[i])



beauties = np.array(beauties)

j = 0

def check(x):

    return np.sum(beauties&x == x) >= K



answer = 0

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

    if check(answer + (1 << i)):

        answer += 1 << i



print(answer)

# 00

import sys

import numpy as np

import itertools



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N, K = lr()

A = np.array([0] + lr())

Acum = A.cumsum()

sum_range = Acum[:, None] - Acum[None, :]

sum_range = sum_range[sum_range>0]



def check(x):

    return np.sum(sum_range&x == x) >= K



answer = 0

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

    if check(answer + (1 << i)):

        answer += 1 << i



print(answer)

# 00

import sys
import numpy as np
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
A = np.array([0] + lr())
A_cum = A.cumsum().tolist()
beauties = []
for i, j in itertools.combinations(list(range(N + 1)), 2):
    beauties.append(A_cum[j] - A_cum[i])
beauties = np.array(beauties)
j = 0


def check(x):
    return np.sum(beauties & x == x) >= K


answer = 0
for i in range(40, -1, -1):
    if check(answer + (1 << i)):
        answer += 1 << i
print(answer)
# 00

import sys
import numpy as np
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
A = np.array([0] + lr())
Acum = A.cumsum()
sum_range = Acum[:, None] - Acum[None, :]
sum_range = sum_range[sum_range > 0]


def check(x):
    return np.sum(sum_range & x == x) >= K


answer = 0
for i in range(40, -1, -1):
    if check(answer + (1 << i)):
        answer += 1 << i
print(answer)
# 00

-A_cum = A.cumsum().tolist() -beauties = [] -for i, j in itertools.combinations(list(range(N + 1)), 2): -    beauties.append(A_cum[j] - A_cum[i]) -beauties = np.array(beauties) -j = 0 +Acum = A.cumsum() +sum_range = Acum[:, None] - Acum[None, :] +sum_range = sum_range[sum_range > 0] -    return np.sum(beauties & x == x) >= K +    return np.sum(sum_range & x == x) >= K