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

namespace _19._12._2021._1
{
    class Program
    {
        static void Main(string[] args)
        {
            string []nz = Console.ReadLine().Split();
            int n = int.Parse(nz[0]), k = int.Parse(nz[1]);
            nz = Console.ReadLine().Split();
            var a = new List<int>();
            for (int i = 0; i < n; i++) 
            {
                a.Add(int.Parse(nz[i]));
            }
            a.Add(a[0]);
            Console.WriteLine(a[a.IndexOf(k)+1]);
            Console.ReadLine();
        }
    }
}