object Main extends App {
  import scala.io.StdIn._

  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  val numbers = 0L +: readLine.trim.split(' ').map(_.toLong)
  for (i ← numbers.indices.tail){
    numbers(i) += numbers(i - 1)
  }
  var result = 0L
  var rest = numbers.indices.flatMap(left ⇒ (left + 1 to n).map(right ⇒ numbers(right) - numbers(left)))
  for (digit ← (0 until 63).reverse){
    val filtered = rest.filter(l ⇒ (l & (1 << digit)) != 0)
    if (filtered.length >= k){
      result |= 1 << digit
      rest = filtered
    }
  }
  println(result)
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
  }
}