#include <bits/stdc++.h>
using namespace std;
long long a[100] = {};
long long sum[100] = {};
long long m = (long long)1 << 59;
int main() {
  long long n = 0, k = 0;
  long long ans = 0;
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = a[i] + sum[i - 1];
  }
  for (long long i = 60; i > 0; i--) {
    long long t = ans | m;
    bool dp[55][55] = {};
    dp[0][0] = true;
    for (long long d = 1; d <= k; d++)
      for (long long s = 1; s <= n; s++)
        for (long long p = 0; p < s; p++)
          if (dp[p][d - 1] && (((sum[s] - sum[p]) & t) == t)) dp[s][d] = true;
    if (dp[n][k] == true) ans = t;
    m >>= 1;
  }
  cout << ans;
  return 0;
}
