#include <bits/stdc++.h>
using namespace std;
const long long int MAX_N = 1 << 17;
using namespace std;
signed main() {
  long long int n, k;
  std::cin >> n >> k;
  std::vector<long long int> a(n, 0);
  for (long long int i = 0; i < n; i++) {
    long long int temp;
    std::cin >> temp;
    a[i] = temp;
  }
  std::vector<long long int> sum;
  for (long long int i = 0; i < n; i++) {
    sum.push_back(a[i]);
    for (long long int j = i + 1; j < n; j++) {
      sum.push_back(a[j] + sum[sum.size() - 1]);
    }
  }
  long long int out = 0;
  long long int get = 0;
  long long int two = (long long int)1 << 50;
  for (long long int i = 0; i < 50; i++) {
    if (two < 1) {
      break;
    }
    long long int flag = 0;
    for (long long int j = 0; j < sum.size(); j++) {
      if ((sum[j] & (two + out)) == two + out) {
        flag++;
      }
    }
    if (flag >= k) {
      out += two;
    }
    two = two / 2;
  }
  std::cout << out << std::endl;
  return 0;
}
