import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);

void main() {
    int n, k; readf("%d %d\n", &n,&k);
    long[] a = Reads!(long);
    auto sum = a.dup;
    foreach(i; 0..n-1)
        sum[i+1] += sum[i];
    sum = [0L] ~ sum;

    long[] b;
    foreach (i; 0..n+1) foreach (j; i+1..n+1)
        b ~= sum[j] - sum[i];

    // O(m^2) where m = a.length = n(n+1)/2
    auto can = (long mask)
        => b.filter!(i => (i & mask) == mask)
            .array.length.to!int >= k;
    long ans;
    for (long mask = 1L<<50; mask; mask >>= 1) {
        if (can(ans + mask))
            ans += mask;
    }

    writeln(ans);
}