/*
  _      __        __         __        ____                    ___    _                   __
 | | /| / / ___ _ / /_ ____  / /       / __ \  ___  ___        / _ \  (_) ___  ____ ___   / /
 | |/ |/ / / _ `// __// __/ / _ \     / /_/ / / _ \/ -_)      / ___/ / / / -_)/ __// -_) /_/ 
 |__/|__/  \_,_/ \__/ \__/ /_//_/     \____/ /_//_/\__/      /_/    /_/  \__/ \__/ \__/ (_)  
                                                                                             
*/
 
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define allr(v, l, r) v.begin() + l, v.begin() + r;
#define endl "\n"
#define newline cout << endl;
using namespace std;

// constants
const int INF = 1e9;

// functions

// structs
struct ST
{
    vector <int> S;
    
    void cleanse()
    {
        fill(all(S), 0);
    }
    
    ST(int n)
    {
        S.resize(n << 2);
    }
    
    void build(int u, int l, int r, vector <int> &vec)
    {
        if (l == r)
        {
            S[u] = vec[l];
            return;
        }
        
        int mid = (l + r) / 2;
        build(u << 1, l, mid, vec);
        build(u << 1 | 1, mid + 1, r, vec);
        
        S[u] = (S[u << 1] | S[u << 1 | 1]);
    }
    
    int ask(int u, int l, int r, int lfl, int lfr)
    {
        if (lfl > r || lfr < l)
        {
            return 0;
        }
        if (lfl <= l && r <= lfr)
        {
            return S[u];
        }
        
        int mid = (l + r) / 2;
        return (ask(u << 1, l, mid, lfl, lfr) | ask(u << 1 | 1, mid + 1, r, lfl, lfr));
    }
};

// globals

// notes
/*
 -stuff you should look for-
* int overflow, array bounds
* special cases (n=1?)
* do something instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH

continue - skip the rest in the loop
*/

void solve()
{
    int n, K;
    cin >> n >> K;
    vector <int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    
    ST G(n + 1);
    G.build(1, 1, n, a);
    
    vector <vector <int> > dp(n + 1, vector <int>(K + 1, 0));
    function <void(int, int, int, int, int)> calc = [&](int l, int r, int optl, int optr, int curk)
    {
        if (optl > optr || l > r)
        {
            return;
        }
        
        int mid = (l + r) / 2;
        int k = -1;
        for (int i = optl; i <= min(mid - 1, optr); i++)
        {
            int cur = (dp[i - 1][curk] ^ G.ask(1, 1, n, i, mid));
            if (cur > dp[mid][curk])
            {
                dp[mid][curk] = cur;
                k = i;
            }
        }
        
        calc(l, mid - 1, optl, k, curk);
        calc(mid + 1, r, k, optr, curk);
    };
    
    cout << dp[n][K];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int testcases = 1;
    // cin >> testcases;
    while (testcases--)
    {
        solve();
        newline
    }
}

/*
$$$$$$$$\ $$$$$$$$\ 
$$  _____|\____$$  |
$$ |          $$  / 
$$$$$\       $$  /  
$$  __|     $$  /   
$$ |       $$  /    
$$$$$$$$\ $$$$$$$$\ 
\________|\________|
*/