#include<bits/stdc++.h>

using namespace std;

using int64 = long long;

int main() {
  int N, K, A[1000];
  cin >> N >> K;
  for(int i = 0; i < N; i++) cin >> A[i];

  auto check = [&](int64 V) {
    int64 ret = 0;
    for(int i = 0; i < N; i++) {
      int64 all = 0;
      for(int j = i; j < N; j++) {
        all += A[j];
        if((all & V) >= V) ++ret;
      }
    }
    return ret >= K;
  };

  int64 bit = 0;
  for(int64 i = 50; i >= 0; i--) {
    if(check(bit | (1LL << i))) bit |= 1LL << i;
  }
  cout << bit << endl;
}