#include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int N,M; cin >> N >> M; int cards[51] = {0}; int cards_s[51] = {0}; for (int i = 0;i <=N;i++){ cards[i] = i; } for (int i = 0;i < M;i++){ int c; cin >> c; for (int j = 0;j <=N;j++){ cards_s[j] = cards[j]; } cards_s[1] = cards[c]; for (int j = 2;j<=c;j++){ cards_s[j] = cards[j-1]; } for (int j = 0;j <=N;j++){ cards[j] = cards_s[j]; } } cout << cards[1] << endl; return 0; }