#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #define INF 1050000000 using namespace std; int main(void) { int n, m; int x[50]; int a, o; cin >> n >> m; for (int i = 1; i <= n; i++) { x[i] = i; } for (int i = 0; i < m; i++) { cin >> a; o = x[a]; for (int j = a - 1; j >= 1; j--) { x[j + 1] = x[j]; } x[1] = o; } cout << x[1] << endl; }