#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	vector <int> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}	
	vector <ll> vec;
	for(int i = 0; i < n; i++){
		ll curr = 0;
		for(int j = i; j < n; j++){
			curr += v[j];
			vec.push_back(curr);
		}
	}
	ll res = 0;
	for(int i = 63; i >= 0; i--){
		int cnt = 0;
		for(auto x : vec){
			if(x & (1LL << i)) cnt++;
		}
		if(cnt >= k){
			res += (1LL << i);
			vector <ll> next;
			for(auto x : vec){
				if(!(x & (1LL << i))) continue;
				next.push_back(x);
			}
			vec = next;
		}
	}
	cout << res;
}