#include <bits/stdc++.h>
#pragma gcc optimize(O3)
using namespace std;
long long INF = static_cast<long long>(2e18);
long long inf = static_cast<long long>(1e9 + 7);
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
vector<vector<set<long long> > > dp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> vals(n);
  dp.resize(k, vector<set<long long> >(n));
  for (auto& it : vals) cin >> it;
  for (long long i = n - 2; i >= 0; --i) vals[i] += vals[i + 1];
  for (long long i = n - 1; i >= 0; --i) dp[0][i].insert(vals[i]);
  if (k == 1) {
    cout << vals[0];
    return 0;
  }
  long long res = 0;
  for (long long i = 1; i < k; i++) {
    for (long long j = n - 1 - i; j >= k - i - 1; --j) {
      for (long long q = j + 1; q < n - i + 1; ++q) {
        for (auto& it : dp[i - 1][q]) {
          if (i == (k - 1) && (!j)) {
            res = max(res, ((vals[j] - vals[q]) & it));
          } else
            dp[i][j].insert((vals[j] - vals[q]) & it);
        }
      }
    }
  }
  cout << res;
  return 0;
}
