using System;
using System.Linq;

namespace MyShootingStar
{
    class Program
    {
        static int lokacija(int[] niz, int trazeno)
        {
            int rez = 0;
            for (int i = 0; i < niz.Length; i++)
            {
                if (niz[i] == trazeno)
                {
                    rez = i;
                    break;
                }
            }
            return rez; 
        }
        public static void Main(String[] args)
        {
            string s1 = Console.ReadLine();
            int N = Convert.ToInt32(s1.Split(' ')[0]);
            int K = Convert.ToInt32(s1.Split(' ')[1]);
            string[] s2 = Console.ReadLine().Split();
            int[] niz = new int[N];
            for (int i = 0; i < N; i++)
                niz[i] = Convert.ToInt32(s2[i]);
            Console.WriteLine(niz[(lokacija(niz, K) + 1) % niz.Length]);
        }
    }
}