#include "bits/stdc++.h"
using namespace std;
const int maxn = 1024;
int main(){
	int n, k;
	cin >> n >> k;
	vector<long long> a(n);
	for(auto & v : a) cin >> v;
	vector<long long> ways;
	for(int e = 0; e < n; e++){
		long long s = 0;
		for(int f = e; f < n; f++){
			s += a[f];
			ways.push_back(s);
		}
	}
	long long as = 0;
	for(int e = 60; e >= 0; e--){
		int cnt = 0;
		for(auto & v : ways) if(v&(1ll<<e)) cnt++;
		if(cnt >= k){
			vector<long long> nxt;
			for(auto & v : ways) if(v&(1ll<<e)) nxt.push_back(v);
			as |= 1ll<<e;
			ways = nxt;
		}
	}
	cout << as << endl;
	return 0;
}
