#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define lint long long int /* vectoral(26); al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; vectorAL(26); AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; */ int main() { int N, M; cin >> N >> M; vectorveca(M); for (int ia = 0; ia < M; ia++) { cin >> veca.at(ia); } vectorvec1(N); for (int ib = 0; ib < N; ib++) { vec1.at(ib) = ib + 1; } vectorvec2(N); for (int ic = 0; ic < N; ic++) { vec2.at(ic) = vec1.at(ic); } for (int id = 0; id < M; id++) { for (int ie = 0; ie < veca.at(id)-1; ie++) { vec2.at(ie + 1) = vec1.at(ie); } vec2.at(0) = vec1.at(veca.at(id) - 1); for (int ig = 0; ig < N; ig++) { vec1.at(ig) = vec2.at(ig); } } cout << vec1.at(0) << endl; }