using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Carobnjak
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int n = int.Parse(str[0]);
            int k = int.Parse(str[1]);
            int[] a = new int[n];
            str = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                a[i] = int.Parse(str[i]);
            int p = 0;
            int q = 0;
            int c = 0;
            for (int i = 0, j = n - 1; c < k - 1; c++)
            {
                if (a[i] >= a[j])
                {
                    a[i] = a[i] - a[j];
                    a[j] = 15235;
                    p = i;
                    j--;
                }
                else
                {
                    a[j] = a[j] - a[i];
                    a[i] = 15235;
                    q = j;
                    i++;
                }
            }
            Console.WriteLine(a[p] != 15235 ? a[p] : a[q]);
        }
    }
}