#include<bits/stdc++.h>
using namespace std;

typedef long long Int;

inline Int TWO(int e) { return 1LL << e; }

int main() {
	int n,k;cin>>n>>k;
	vector<Int>ca(n+1);for(int i=0;i<n;i++){int x;cin>>x;ca[i+1]=ca[i]+x;}
	vector<Int> cum; for (int l=0; l<n; l++) for(int r=l; r<n; r++) cum.push_back(ca[r+1] - ca[l]);
	Int S = 0;
	for (int b=60; b>=0; b--) {
		int cnt=0; for (Int v : cum) if (v & TWO(b)) cnt++;
		if (cnt >= k) {
			S |= TWO(b);
			vector<Int> cum2;
			for (Int v : cum) if (v & TWO(b)) cum2.push_back(v);
			cum = cum2;
		}
	}
	cout << S << endl;
}
