import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.StreamTokenizer

class B

fun main( args: Array<String> ) {
    val st = StreamTokenizer( BufferedReader( InputStreamReader( System.`in` ) ) )
    val n = st.nextInt()
    val k = st.nextInt()
    val a = LongArray( n, { st.nextInt().toLong() } )
    var s = LongArray( n * ( n + 1 ) / 2 )
    var curLen = 0
    for ( i in a.indices ) {
        var sum = 0L
        for ( j in i .. a.lastIndex ) {
            sum += a[j]
            s[curLen ++] = sum
        }
    }
    var r = 0L
    for ( p in 40 downTo 0 ) {
        val newS = LongArray( curLen )
        var cur = 0
        for ( sum in s ) {
            if ( ( sum and ( 1L shl p ) ) > 0 ) {
                newS[cur ++] = sum
            }
        }
        if ( cur >= k ) {
            s = newS
            curLen = cur
            r += 1L shl p
        }
    }
    println( r )
}

private fun StreamTokenizer.nextInt(): Int {
    nextToken()
    return nval.toInt()
}
