#include using namespace std; typedef long long ll; typedef vector VI; typedef vector VVI; #define ITER(c) __typeof__((c).begin()) #define FOREACH(it, c) for (ITER(c) it=(c).begin(); it != (c).end(); ++it) #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) #define RREP(i, n) for(int(i)=(n)-1;(i)>=0;--(i)) const int MOD = (int)1e9+7; int main(){ int N,M; cin >> N >> M; int A[100100]; REP(i,M){ cin >> A[i]; } VI v; REP(i,N){ v.push_back(i+1); } REP(i,M){ int k = v[A[i]-1]; RREP(j,A[i]-1){ v[j+1] = v[j]; } v[0] = k; } cout << v[0] << endl; }