#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e5;
long long N, K, arr[100], power_[100], dp[100][100];
bool subset(long long X, long long Y) { return (X & Y) == Y; }
bool ok(long long X) {
  long long sum;
  for (long long A = 0; A <= N; A++)
    for (long long B = 0; B <= K; B++) dp[A][B] = 0;
  dp[0][0] = 1;
  for (long long A = 1; A <= N; A++) {
    sum = 0;
    for (long long B = A; B >= 1; B--) {
      sum += arr[B];
      if (subset(sum, X)) {
        for (long long C = K; C >= 1; C--)
          dp[A][C] = max(dp[A][C], dp[B - 1][C - 1]);
      }
    }
  }
  return (dp[N][K] == 1);
}
long long solve() {
  long long res = 0;
  power_[0] = 1;
  for (long long A = 1; A <= 55; A++)
    power_[A] = (1ll) * power_[A - 1] + (1ll) * power_[A - 1];
  cin >> N >> K;
  for (long long A = 1; A <= N; A++) cin >> arr[A];
  for (long long A = 55; A >= 0; A--) {
    res ^= (power_[A]);
    if (ok(res)) continue;
    res ^= (power_[A]);
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cout << solve() << "\n";
  return 0;
}
