#include <bits/stdc++.h>
using namespace std;
long long int a[1005];
long long int sum[1005];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  vector<long long int> vec;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      vec.push_back(sum[j] - sum[i - 1]);
    }
  }
  long long int ans = 0;
  for (int b = 40; b >= 0; b--) {
    long long int x = ans | (1LL << b);
    int count = 0;
    for (auto v : vec) {
      if ((x & v) == x) {
        count++;
      }
    }
    if (count >= k) {
      ans = x;
    }
  }
  printf("%lld\n", ans);
}
