N,K=gets.chomp.split(" ").map{|a|a.to_i}
A=gets.chomp.split(" ").map{|a|a.to_i}
Asum = Array.new(A.size)
Asum[0] = A[0]
for i in 1..(N-1)
	Asum[i] = Asum[i-1] + A[i]
end
i = 0
SUM = Array.new(N*(N+1)/2)
for l in 0..(N-1)
	for r in l..(N-1)
		SUM[i] = Asum[r] - Asum[l] + A[l]
		i += 1
	end
end
# p SUM
d = 2**38
x = 0
while(d > 0)
	# puts "test : #{d}"
	cnt = 0
	for i in 0..(N*(N+1)/2 - 1)
		cnt += 1 if (x+d) & SUM[i] == (x+d)
	end
	# puts "cnt : #{cnt}"
	x += d if cnt >= K
	d /= 2
end
puts x
