#include "bits/stdc++.h" using namespace std; int main() { int N,M,temp; cin >> N >> M; int A[M]; int B[N]; int temp1[N]; for(int i = 0; i < M; i++) { cin >> A[i]; } for(int i = 0; i < N; i++) { B[i] = i+1; } for(int i = 0; i < M; i++) { temp = B[A[i]-1]; temp1[0] = B[0]; for(int k = 0; k < A[i]-1; k++){ temp1[k+1] = B[k+1]; B[k+1] = temp1[k]; } B[0] = temp; } cout << B[0] << endl; return 0; }