#include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i, a, n) for (int i = a; i < n; i++) #define REP(i, n) for(int i = 0; i < n; i++) struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star; int main(){ int n, m; cin >> n >> m; int A[m]; REP(i, m){ int tmp; cin >> tmp; A[i] = tmp - 1; } vector C(n); //card REP(i, n) C[i] = i + 1; REP(i, m){ C.insert(C.begin(), C[A[i]]); C.erase(C.begin() + A[i] + 1); } cout << C[0] << endl; return 0; }