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

namespace Petlja2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);
            LinkedList<int> Lista = new LinkedList<int>();
            string[] s1 = Console.ReadLine().Split();
            for (int i = 0; i < N; i++)
            {
                Lista.AddLast(int.Parse(s1[i]));
            }
            if (Lista.Find(K).Next == null)
            {
                Console.WriteLine(Lista.First.Value);
            }
            else
            {
                Console.WriteLine(Lista.Find(K).Next.Value);
            }
        }
    }
}