var sum  = function(arr) {
    return arr.reduce(function(prev, current, i, arr) {
        return prev+current;
    });
};

function main(arg) {
	var k = Number(arg.split("\n")[0].split(" ")[1])
	arg = arg.split("\n")[1].split(" ").map(e => Number(e))

	var result = []

	for (var i = 0; i < arg.length; i++) {
		var arr = arg.slice(i, arg.length)
		result[i] = []
		for (var j = 0; j < arr.length; j++) {
			var tmp = []
			for (var k = 0; k <= j; k++) {
				tmp.push(arr[k])
			}
			// console.log([sum(tmp),tmp])
			result[i].push(sum(tmp))
			// console.log("")
		}
	}

	var max_n = 0
	var max = 0

	for (var i = 0; i < result.length; i++) {
		for (var j = 0; j < result[i].length; j++) {
			var arr = []
			var v = result[i][j]

			result.slice(i+1, result.length).forEach(e => {
				arr = arr.concat(e)
			})

			for (var k = 0; k < arr.length; k++) {
				var x = v & arr[k]
				if (max < x) {
					max = x
				}
				// console.log(x)
			}
		}
	}
	console.log(max)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));