#include<stdio.h>
#include<vector>
#define int long long
using namespace std;
vector<int> vi1,vi2;
int n,k,a,sum[1000000],tmp,pow[100],cnt,ans;
signed main(){
	scanf("%lld %lld", &n,&k);
	for(int i=1;i<=n;i++){
		scanf("%lld", &a);
		sum[i]=sum[i-1]+a;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			tmp=sum[i]-sum[j-1];
			vi1.push_back(tmp);
		}
	}
	pow[0]=1;
	for(int i=1;i<=42;i++){
		pow[i]=pow[i-1]*2;
	}
	for(int i=42;i>=0;i--){
		cnt=0;
		vi2.clear();
		for(int j=0;j<vi1.size();j++){
			if(vi1[j]>=pow[i]){
				tmp=vi1[j]-pow[i];
				vi1[j]-=pow[i];
				cnt++;
				vi2.push_back(tmp);
			}
		}
		if(cnt>=k){
			vi1.clear();
			for(int j=0;j<vi2.size();j++){
				vi1.push_back(vi2[j]);
			}
			ans+=pow[i];
		}
	}
	printf("%lld", ans);
}