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

int main(void) {
    int n, k;
    cin >> n >> k;

    vector<long> a(n);
    for(auto &x: a) cin >> x;
    for(int i=0; i<n-1; i++)
        a[i+1] += a[i];

    vector<long> b;
    for(int i=0; i<n; i++) {
        b.push_back(a[i]);
        for(int j=0; j<i; j++)
            b.push_back(a[i]-a[j]);
    }

    long r = 0;
    for(long x=1LL<<40; x; x>>=1) {
        r |= x;
        long cnt = 0;
        for(auto &y: b) cnt += (r & y) == r;
        if(cnt < k) r &= ~x;
    }

    cout << r << endl;
}
