/* -*- coding: utf-8 -*- * * 123.cc: No.123 カードシャッフル - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 50; /* typedef */ /* global variables */ int cs[MAX_N]; /* subroutines */ /* main */ int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cs[i] = i + 1; while (m--) { int ai; cin >> ai; ai--; int c = cs[ai]; for (int i = ai - 1; i > 0; i--) cs[i] = cs[i - 1]; cs[0] = c; } printf("%d\n", cs[0]); return 0; }