package madjionicar;

import java.util.Arrays;
import java.util.Scanner;

public class Madjionicar {

    public static int[] preseci(int a, int[] spil) {
        int[] p = new int[spil.length];

        for (int i = 0; i < p.length - a; i++) {
            p[i] = spil[i + a];

        }
        for (int k = 0; k < a; k++) {
            p[p.length - a + k] = spil[k];
        }

        return p;
    }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int n = in.nextInt(), k = in.nextInt();
        int[] spil = new int[n];

        for (int i = 0; i < n; i++) {
            spil[i] = in.nextInt();
        }

        int[] p = new int[n];

        p = preseci(2, spil);

        int karta = -1;
        for (int i = 0; i < n; i++) {
            if (p[i] == k) {
                karta = i;
                break;
            }

        }

        System.out.println(p[karta+1]);
    }

}