Mr Keks is a typical white-collar in Byteland.

He has a bookshelf in his office with some books on it, each book has an integer positive price.

Mr Keks defines the value of a shelf as the sum of books prices on it. 

Miraculously, Mr Keks was promoted and now he is moving into a new office.

He learned that in the new office he will have not a single bookshelf, but exactly k bookshelves. He decided that the beauty of the k shelves is the [bitwise AND](https://en.wikipedia.org/wiki/Bitwise_operation#AND) of the values of all the shelves.

He also decided that he won't spend time on reordering the books, so he will place several first books on the first shelf, several next books on the next shelf and so on. Of course, he will place at least one book on each shelf. This way he will put all his books on k shelves in such a way that the beauty of the shelves is as large as possible. Compute this maximum possible beauty.

Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 50) — the number of books and the number of shelves in the new office.

The second line contains n integers a_1, a_2, … a_n, (0 < a_i < 2^{50}) — the prices of the books in the order they stand on the old shelf.

Output

Print the maximum possible beauty of k shelves in the new office.

Examples

Input

10 4
9 14 28 1 7 13 15 29 2 31


Output

24


Input

7 3
3 14 15 92 65 35 89


Output

64

Note

In the first example you can split the books as follows:

$$$(9 + 14 + 28 + 1 + 7) \& (13 + 15) \& (29 + 2) \& (31) = 24.$$$

In the second example you can split the books as follows:

$$$(3 + 14 + 15 + 92) \& (65) \& (35 + 89) = 64.$$$
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write


def in_arr():
    return map(int,raw_input().split())


def pr_num(n):
    stdout.write(str(n)+'\n')


def pr_arr(arr):
    for i in arr:
        stdout.write(str(i)+' ')
    stdout.write('\n')


range = xrange # not for python 3.0+
n,k=in_arr()
pre=[0]*(n+1)

l=in_arr()
for i in range(1,n+1):
    pre[i]+=pre[i-1]
    pre[i]+=l[i-1]
ans=0
for bit in range(60,-1,-1):
    tar=ans|(1<<bit)
    dp=[[0 for i in range(n+1)] for i in range(k+1)]
    dp[0][0]=1
    for j in range(1,k+1):
        for k2 in range(1,n+1):
            for k1 in range(k2):
                if dp[j-1][k1] and (pre[k2]-pre[k1])&tar==tar:
                    dp[j][k2]=1
    if dp[k][n]:
        ans=tar
print ans
