#include using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) #define ALL(a) (a).begin(),(a).end() int main() { int n, m; cin >> n >> m; vector card(n); REP(i, n) card[i] = i; REP(i, m) { int t; cin >> t; card.insert(card.begin(), card[t + 1]); card.erase(card.begin() + (t + 1) + 1); } cout << card[0] << endl; return 0; }