
object Main extends App {

  import scala.io.StdIn._


  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  val series = readLine.trim.split(' ').map(_.toLong)
  var list: List[Long] = series.head :: Nil
  for (i ← 0 until n - 1){
    series(i + 1) += series(i)
    list ::= series(i + 1)
  }
  for (i ← 0 until n - 2){
    for (j ← (i + 2) until n){
      list ::= series(j) - series(i)
    }
  }
  for (bit ← 40 to 0 by -1){
    val filtered = list.filter(l ⇒ (l & (1L << bit)) != 0)
    if (filtered.size >= k){
      list = filtered
    }
  }
  println(
    list.foldLeft((1L << 63) - 1){case (a, b) ⇒ a & b}
  )
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}