#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<long long> PS;
int countMask(int a) {
  int ret = 0;
  for (int x : PS) {
    if ((x & a) == a) {
      ret++;
    }
  }
  return ret;
}
int main() {
  cin >> n >> k;
  long long a[1000];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = i; j < n; j++) {
      sum += a[j];
      PS.push_back(sum);
    }
  }
  int mask = 0;
  for (int i = 40; i >= 0; i--) {
    if (countMask(mask | (1LL << i)) >= k) {
      mask |= (1LL << i);
    }
  }
  cout << mask << endl;
  return 0;
}
