#include <bits/stdc++.h>
using namespace std;
const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static long long int INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
signed main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<long long int> A(n), Cum(n + 1);
  Cum[0] = 0;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    Cum[i + 1] = Cum[i] + A[i];
  }
  vector<long long int> P;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n + 1; ++j) {
      P.push_back(Cum[j] - Cum[i]);
    }
  }
  sort(P.rbegin(), P.rend());
  vector<long long int> cur = P;
  for (int k = 64; k >= 0; --k) {
    vector<long long int> tmp;
    for (int e = 0; e < cur.size(); ++e) {
      if (cur[e] & (1LL << k)) tmp.push_back(cur[e]);
    }
    if (tmp.size() >= k) cur = tmp;
  }
  long long int res = cur[0];
  for (int i = 0; i < k; ++i) {
    res &= cur[i];
  }
  cout << res << endl;
  return 0;
}
