import java.util.*

fun main(args:Array<String>){
    val (n,k) = readLine()!!.split(" ").map{it.toInt()}
    val a = readLine()!!.split(" ").map{it.toLong()}
    var b = LongArray(n * (n + 1) / 2)
    var it = 0
    for(i in 0 until n){
        var sum = 0L
        for(j in i until n){
            sum += a[j]
            b[it] = sum
            it++
        }
    }
    var ans = 0L
    var t = 1L shl 62
    var t1 = 62
    var c = BooleanArray(b.size){true}
    while(t > 0){
        var cnt = 0
        for(i in 0 until b.size){
            if(c[i] && (b[i] shr t1) and 1 == 1L) cnt++
        }
        if(cnt >= k){
            for(i in 0 until b.size){
                if(c[i] && (b[i] shr t1) and 1 == 0L) c[i] = false
            }
            ans += t
        }
        t /= 2
        t1--
    }
    println(ans)
}
