#include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) vector nex(const vector &pre) { ll n = pre.size(); set st; rep(i, n + 10) st.insert(i); map mp; auto add = [&](ll v) { if (++mp[v] == 1 && st.count(v) == 1) st.erase(v); }; auto del = [&](ll v) { if (--mp[v] == 0) st.insert(v); }; rep(i, n) add(pre[i]); vector res; rep(i, n) { ll now = *st.begin(); res.push_back(now); add(now); del(pre[i]); } ll now = *st.begin(); res.push_back(now); return res; } void solve() { ll n, x; cin >> n >> x, x--; vector a(n); rep(i, n) cin >> a[i]; if (x < n) { cout << a[x] << '\n'; return; } auto b = nex(a); x -= n; x %= n + 1; cout << b[x] << '\n'; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int T = 1; for (int t = 0; t < T; t++) { solve(); } return 0; }