#include <iostream>

using namespace std;

int main()
{
    int n,k;
    cin >> n >>k;
    int a[n];
    int h = sizeof(a) / sizeof(a[0]);
    for (int i = 0; i < n; i++) {
        cin >> a[i]; 
}
    if(k == a[h-1]) cout << a[0];
    else cout<<a[(sizeof(a)/sizeof(int))-1];


    return 0;
}