#include #include #include #include #define repeat(i,n) for (int i = 0; (i) < (n); ++(i)) #define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x) using namespace std; int main() { int n, m; cin >> n >> m; vector b(n); whole(iota, b, 0); repeat (i,m) { int a; cin >> a; -- a; rotate(b.begin(), b.begin()+a, b.begin()+a+1); } cout << b.front()+1 << endl; return 0; }