import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum mod = 10L^^9 + 7;
enum inf = 10^^9;

void main() {
    int n, k;
    scan(n, k);

    auto a = readln.split.to!(long[]);

    auto b = new long[][](64, 0);

    auto ac = new long[](n + 1);
    foreach (i ; 0 .. n) {
        ac[i+1] = ac[i] + a[i];
    }

    foreach (i ; 0 .. n) {
        foreach (j ; i + 1 .. n + 1) {
            auto ss = ac[j] - ac[i];
            debug {
                writefln("(%d, %d) : %d", i, j, ss);
            }
            foreach (l ; 0 .. 64) {
                if (ss & (1L << l)) {
                    b[l] ~= ss;
                }
            }
        }
    }

    debug {
        writefln("%(%s\n%)", b);
    }

    long ans;

    for (int r = 63; r >= 0; r--) {
        if (b[r].length < k) {
            continue;
        }

        debug {
            writeln(r, " ", b[r]);
        }

        ans += (1L<<r);

        foreach (i ; 0 .. r) {
            b[i] = null;
        }

        foreach (bi ; b[r]) {
            foreach (i ; 0 .. r) {
                if (bi & (1L << i)) {
                    b[i] ~= bi;
                }
            }
        }
    }

    writeln(ans);
}





























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}