#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
long long n, k, a[1008];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (long long i = (1); i <= (n); i++) {
    cin >> a[i];
  }
  a[0] = 0LL;
  for (long long i = (1); i <= (n); i++) {
    a[i] += a[i - 1];
  }
  vector<long long> v;
  for (long long i = (1); i <= (n); i++) {
    for (long long j = (i); j <= (n); j++) {
      v.push_back(a[j] - a[i - 1]);
    }
  }
  long long ans = 0LL;
  for (long long b = (40); b >= (0); b--) {
    long long bit = (1LL << b);
    long long cnt = 0;
    vector<long long> u;
    for (long long i = 0; i < v.size(); i++) {
      if (v[i] >= bit) {
        cnt++;
        u.push_back(v[i] - bit);
      }
    }
    if (cnt >= k) {
      ans += bit;
      v.swap(u);
    }
  }
  cout << (ans) << endl;
  return 0;
}
