#include <vector>
#include <iostream>
using namespace std;
const int bits = 40;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	vector<long long> S(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		S[i + 1] = S[i] + A[i];
	}
	vector<long long> v;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j <= N; ++j) {
			v.push_back(S[j] - S[i]);
		}
	}
	long long ans = 0;
	for (int i = bits - 1; i >= 0; --i) {
		long long w = ans + ((long long)(1) << i);
		int cnt = 0;
		for (long long j : v) {
			if ((j & w) == w) {
				++cnt;
			}
		}
		if (cnt >= K) ans += (long long)(1) << i;
	}
	cout << ans << endl;
	return 0;
}