#include <bits/stdc++.h>
using namespace std;
long long int n, k, A[100], S[100];
bool dp[55][55];
bool check(long long int targ) {
  memset(dp, false, sizeof(dp));
  dp[0][0] = 1;
  long long int i, j, x;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= i; ++j) {
      if (((S[i] - S[j - 1]) & targ) == targ) {
        for (x = 0; x <= k; ++x) {
          if (dp[j - 1][x]) dp[i][x + 1] = 1;
        }
      }
    }
  }
  return dp[n][k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  long long int i, j, x, y, z, a, b, c;
  cin >> n >> k;
  for (i = 1; i <= n; ++i) cin >> A[i];
  for (i = 1; i <= n; ++i) S[i] = A[i] + S[i - 1];
  long long int ans = 0;
  for (i = 55; i >= 0; --i) {
    if (check(ans | (1ll << i))) ans |= (1ll << i);
  }
  cout << ans << endl;
  return 0;
}
