#include <bits/stdc++.h>
using namespace std;
const long long maxn = 70;
long long a[maxn], ps[maxn], dp[maxn][maxn], n, k;
bool check(long long h) {
  memset(dp, false, sizeof dp);
  dp[0][0] = true;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= k; j++)
      for (long long x = 0; x < i; x++)
        if (((ps[i] - ps[x]) & h) == h) dp[i][j] |= dp[x][j - 1];
  return dp[n][k];
}
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) cin >> a[i], ps[i] = ps[i - 1] + a[i];
  long long ans = 0;
  for (long long i = 60; ~i; i--)
    if (check(ans ^ (1ll << i))) ans ^= 1ll << i;
  cout << ans;
  return 0;
}
