using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading;
using System.Xml.Schema;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N, K;
        private int[] A;
        private long[] Sum;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            K = sc.NextInt();
            A = sc.IntArray();
        }

        public void Solve()
        {
            Scan();
            Sum = new long[N + 1];
            for (int i = 0; i < N; i++)
            {
                Sum[i + 1] = Sum[i] + A[i];
            }
            var list = new List<long>();
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j <= N; j++)
                {
                    list.Add(Calc(i, j));
                }
            }
            Console.WriteLine(Ans(40, list));
        }

        private long Ans(int n, List<long> list)
        {
            if (n < 0 || list.Count < K)
            {
                return 0;
            }
            long b = 1L << n;
            //Console.WriteLine(b);
            var l = new List<long>();
            int cnt = 0;
            foreach (var l1 in list)
            {
                if ((b & l1) > 0)
                {
                    cnt++;
                    l.Add(l1);
                }
            }
            if (cnt < K)
            {
                return 0 + Ans(n - 1, list);
            }
            else
            {
                return b + Ans(n - 1, l);
            }
        }

        private long Calc(int left, int right)
        {
            return Sum[right] - Sum[left];
        }

        static void Main() => new Program().Solve();
    }


}

Measured memory_bytes: 31696