using System;
using System.Linq;

namespace MyShootingStar
{
    class Program
    {
        public static void Main(String[] args)
        {
            string s1 = Console.ReadLine();
            string[] s2 = Console.ReadLine().Split();
            int N = Convert.ToInt32(s1.Split(' ')[0]);
            int K = Convert.ToInt32(s1.Split(' ')[1]);
            int[] niz = new int[N];
            for (int i = 0; i < N; i++)
            {
                niz[i] = Convert.ToInt32(s2[i]);
            }
            int rez = 0;
            int krece = 0;
            int staje = niz.Length - 1;
            for (int i = 0; i < K - 1; i++)
            {
                if (niz[krece] - niz[staje] > niz[staje] - niz[krece])
                {
                    niz[krece] -= niz[staje];
                    staje -= 1;
                    rez = niz[krece];
                }
                else if (niz[staje] - niz[krece] > niz[krece] - niz[staje])
                {
                    niz[staje] -= niz[krece];
                    krece += 1;
                    rez = niz[staje];
                }
            }
            Console.WriteLine(rez);

        }
    }
}