import sys

from itertools import accumulate



sys.setrecursionlimit(10 ** 7)

input = sys.stdin.readline

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

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

    A = list(map(int, input().split()))



    R = [0] + list(accumulate(A))

    subs = []

    for left in range(n):

        for right in range(left + 1, n + 1):

            subs.append(R[right] - R[left])



    res = 0

    for mask in reversed(list(range(40))):

        if len(subs) == 0:

            break

        tmp = []

        for i in range(len(subs)):

            if subs[i] & (1 << mask):

                tmp.append(subs[i])

        if len(tmp) >= k:

            res += 1 << mask

            subs = tmp

    print(res)





if __name__ == '__main__':

    resolve()

import sys

from itertools import accumulate



sys.setrecursionlimit(10 ** 7)

input = sys.stdin.readline

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

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

    A = list(map(int, input().split()))



    R = [0] + list(accumulate(A))

    subs = []

    for left in range(n + 1):

        for right in range(left + 1, n + 1):

            num = R[right] - R[left]

            subs.append(num)



    for i in reversed(list(range(41))):

        tmp = []

        for num in subs:

            if num & (1 << i):

                tmp.append(num)

        if len(tmp) >= k:

            subs = tmp



    res = subs[0]

    for num in subs:

        res &= num

    print(res)





if __name__ == '__main__':

    resolve()

import sys
from itertools import accumulate

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n, k = list(map(int, input().split()))
    A = list(map(int, input().split()))
    R = [0] + list(accumulate(A))
    subs = []
    for left in range(n):
        for right in range(left + 1, n + 1):
            subs.append(R[right] - R[left])
    res = 0
    for mask in reversed(list(range(40))):
        if len(subs) == 0:
            break
        tmp = []
        for i in range(len(subs)):
            if subs[i] & (1 << mask):
                tmp.append(subs[i])
        if len(tmp) >= k:
            res += 1 << mask
            subs = tmp
    print(res)


if __name__ == "__main__":
    resolve()

import sys
from itertools import accumulate

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n, k = list(map(int, input().split()))
    A = list(map(int, input().split()))
    R = [0] + list(accumulate(A))
    subs = []
    for left in range(n + 1):
        for right in range(left + 1, n + 1):
            num = R[right] - R[left]
            subs.append(num)
    for i in reversed(list(range(41))):
        tmp = []
        for num in subs:
            if num & (1 << i):
                tmp.append(num)
        if len(tmp) >= k:
            subs = tmp
    res = subs[0]
    for num in subs:
        res &= num
    print(res)


if __name__ == "__main__":
    resolve()

-    for left in range(n): +    for left in range(n + 1): -            subs.append(R[right] - R[left]) -    res = 0 -    for mask in reversed(list(range(40))): -        if len(subs) == 0: -            break +            num = R[right] - R[left] +            subs.append(num) +    for i in reversed(list(range(41))): -        for i in range(len(subs)): -            if subs[i] & (1 << mask): -                tmp.append(subs[i]) +        for num in subs: +            if num & (1 << i): +                tmp.append(num) -            res += 1 << mask +    res = subs[0] +    for num in subs: +        res &= num