#include "bits/stdc++.h"

using namespace std;

unsigned long sums[5000050];

void solve()
{
	int N, K;
	cin >> N >> K;
	vector<unsigned long> imos(N+1);
	for (int i = 0; i < N; i++)
	{
		long a;
		cin >> a;
		imos[i+1] = a+imos[i];
	}

	unsigned long ans = 0;

	for (int l = 0; l < N; l++) for (int r = l+1; r <= N; r++)
	{
		sums[N*l+r-l] = imos[r] - imos[l];
	}

	unsigned long b = 1ULL<<60;

	while(b>0)
	{
		int cnt = 0;
		for (auto s : sums)
		{
			cnt += ((ans+b)&s) == ans+b;
		}
		if (cnt >= K) ans += b;
		b >>= 1;
	}

	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}
