from fractions import gcd

from datetime import date, timedelta

from heapq import*

import math

from collections import defaultdict, Counter, deque

import sys

from bisect import *

import itertools

import copy

sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7





def main():

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

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

    

    rui = [a[0]]

    for i in range(1, n):

        rui.append(rui[i - 1] + a[i])

    rui = [0] + rui

    ansl = []

    for i in range(n):

        for j in range(i,n):

            ansl.append(rui[j + 1] - rui[i])

    ansl = sorted(ansl, reverse=True)

    

    cnt = 0

    ansbit = 0

    L = []

    for i in range(51):

        bit = (1 << (50 - i))

        l = []

        for j in range(len(ansl)):

            if ansl[j] & bit == 0:

                l.append(ansl[j])

            else:

                L.append(ansl[j])

                cnt += 1

        if cnt >= k:

            ansbit = i

            break

        else:

            L = []

        # ansl = l



    ans = 0

    for i in range(51):

        bit = (1 << (50 - i))

        LL = []

        cnt = 0

        for j in range(len(L)):

            if L[j] & bit != 0:

                cnt+=1

                LL.append(L[j])



        if cnt >= k:

            L = LL

            ans |= bit



        if len(L) < k:

            break

                



    

    print(ans)

    

                    





if __name__ == '__main__':

    main()

from fractions import gcd

from datetime import date, timedelta

from heapq import*

import math

from collections import defaultdict, Counter, deque

import sys

from bisect import *

import itertools

import copy

sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7





def main():

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

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

    

    rui = [a[0]]

    for i in range(1, n):

        rui.append(rui[i - 1] + a[i])

    rui = [0] + rui

    L = []

    for i in range(n):

        for j in range(i,n):

            L.append(rui[j + 1] - rui[i])



    ans = 0

    for i in range(51):

        bit = (1 << (50 - i))

        LL = []

        cnt = 0

        for j in range(len(L)):

            if L[j] & bit != 0:

                cnt+=1

                LL.append(L[j])



        if cnt >= k:

            L = LL

            ans |= bit



        if len(L) < k:

            break

                



    

    print(ans)

    

                    





if __name__ == '__main__':

    main()

from fractions import gcd
from datetime import date, timedelta
from heapq import *
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy

sys.setrecursionlimit(10**7)
MOD = 10**9 + 7


def main():
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    rui = [a[0]]
    for i in range(1, n):
        rui.append(rui[i - 1] + a[i])
    rui = [0] + rui
    ansl = []
    for i in range(n):
        for j in range(i, n):
            ansl.append(rui[j + 1] - rui[i])
    ansl = sorted(ansl, reverse=True)
    cnt = 0
    ansbit = 0
    L = []
    for i in range(51):
        bit = 1 << (50 - i)
        l = []
        for j in range(len(ansl)):
            if ansl[j] & bit == 0:
                l.append(ansl[j])
            else:
                L.append(ansl[j])
                cnt += 1
        if cnt >= k:
            ansbit = i
            break
        else:
            L = []
        # ansl = l
    ans = 0
    for i in range(51):
        bit = 1 << (50 - i)
        LL = []
        cnt = 0
        for j in range(len(L)):
            if L[j] & bit != 0:
                cnt += 1
                LL.append(L[j])
        if cnt >= k:
            L = LL
            ans |= bit
        if len(L) < k:
            break
    print(ans)


if __name__ == "__main__":
    main()

from fractions import gcd
from datetime import date, timedelta
from heapq import *
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy

sys.setrecursionlimit(10**7)
MOD = 10**9 + 7


def main():
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    rui = [a[0]]
    for i in range(1, n):
        rui.append(rui[i - 1] + a[i])
    rui = [0] + rui
    L = []
    for i in range(n):
        for j in range(i, n):
            L.append(rui[j + 1] - rui[i])
    ans = 0
    for i in range(51):
        bit = 1 << (50 - i)
        LL = []
        cnt = 0
        for j in range(len(L)):
            if L[j] & bit != 0:
                cnt += 1
                LL.append(L[j])
        if cnt >= k:
            L = LL
            ans |= bit
        if len(L) < k:
            break
    print(ans)


if __name__ == "__main__":
    main()

-    ansl = [] +    L = [] -            ansl.append(rui[j + 1] - rui[i]) -    ansl = sorted(ansl, reverse=True) -    cnt = 0 -    ansbit = 0 -    L = [] -    for i in range(51): -        bit = 1 << (50 - i) -        l = [] -        for j in range(len(ansl)): -            if ansl[j] & bit == 0: -                l.append(ansl[j]) -            else: -                L.append(ansl[j]) -                cnt += 1 -        if cnt >= k: -            ansbit = i -            break -        else: -            L = [] -        # ansl = l +            L.append(rui[j + 1] - rui[i])