'use strict'
function _(s){let l=s.split('\n');if(l[l.length-1]=='')l.pop();this.l=l;this.y=0}
_.prototype.ints = function(){return this.l[this.y++].split(' ').map(v=>+v)}
_.prototype.intv = function(){const y=this.y;this.y=this.l.length;return this.l.slice(y).map(v=>+v)}
_.prototype.strv = function(){const y=this.y;this.y=this.l.length;return this.l.slice(y)}
_.prototype.strn = function(n){const y=this.y;this.y+=n;return this.l.slice(y,y+n)}
const __b32 = Math.pow(2,32)
let __pad='0';for(let i=0;i<6;++i){__pad+=__pad}
function isBit64(n){return n >= __b32}
function sepBit64(n){let s=__pad+n.toString(2);return [parseInt(s.slice(-64,-32),2), parseInt(s.slice(-32),2)]}
Number.prototype.BitAnd = function(x){let a=sepBit64(this);let b=sepBit64(x);return parseInt((a[0]&b[0]).toString(2) + ((__pad+(a[1]&b[1]).toString(2)).slice(-32)), 2)}
const $ = new _(require("fs").readFileSync("/dev/stdin", "utf8"));
(()=>{

    // console.log((571).BitAnd(543982570257824931))
const nk = $.ints()
const n = nk[0]
const k = nk[1]
const a = $.ints()

const rr = []
for(let i=0;i<n;i++){
    let s = 0;
    for(let j=i;j<n;j++){
        s+=a[j]
        rr.push(s)
    }
}
rr.sort((a,b)=>b-a)
let res = 0
for(let d=41; d>=0; d--){
    let border = Math.pow(2,d)
    const filtered = rr.filter(e=>(e.BitAnd(res+border)) === (res+border))
    let num = filtered.length
    if(num>=k){
        res += border
    }
}
console.log(res)




})()