#include #include #include #include using namespace std; using namespace atcoder; using namespace __gnu_pbds; using ll=long long; using ld=long double; using vll=vector; using pll=pair; using mint=modint; template using ordered_map=tree,rb_tree_tag,tree_order_statistics_node_update>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ordered_map mp; ll N,M,t=0; cin>>N>>M; for(int i=1;i<=N;++i)mp.insert({i,i}); for(int i=1;i<=M;++i){ ll A; cin>>A; auto it=mp.find_by_order(A-1); ll key=it->first; ll val=it->second; mp.erase(key); mp.insert({t,val}); t--; } auto it=mp.find_by_order(0); cout<second<