#include using namespace std; signed main(){ int N, M; cin >> N >> M; deque< int > dq; for( int i = 1; i <= N; ++i ) dq.emplace_back( i ); for( int i = 0; i < M; ++i ){ int A; cin >> A; int v = dq[ A - 1 ]; dq.erase( dq.begin() + A - 1 ); dq.emplace_front( v ); } cout << dq.front() << endl; return 0; }