/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class BSumANDSubarrays {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    ll n,k;
    void solve(std::istream& cin, std::ostream& cout){
        cin >> n >> k;
        vector<ll> a(n);
        rep(i,n)cin >> a[i];
        vector<ll> c(n+1,0);
        rep(i,n)c[i+1] = c[i] + a[i];

        vector<ll> cand;
        for(int l = 0;l < n;l++){
            for(int r = l+1;r < n+1;r++){
                cand.pb(c[r] - c[l]);
            }
        }
        ll sz = cand.size();
        vector<bool> check(cand.size(),true);
        ll count = cand.size();
        ll ans = 0;
        for(int i = 40;i >= 0;i--){
            ll cnt = 0;
            for(int j = 0;j < sz;j++){
                if(check[j] and (cand[j]>>i)&1)cnt++;
            }
            //cout <<cnt << endl;
            if(cnt < k){
                continue;
            }else{
                ans += (1LL << i);
                for(int j = 0;j < sz;j++){
                    if(check[j] and !((cand[j]>>i)&1)){
                        check[j] = false;
                        count--;
                    }
                }
            }
        }

        cout << ans << endl;


    }
};

int main() {
	BSumANDSubarrays solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6388