#include #define For(i, a, b) for(int i = a; i < b; i++) #define rep(i, n) For(i, 0, n) #define rFor(i, a, b) for(int i = a; i >= b; i--) #define ALL(v) (v).begin(), (v).end() #define rALL(v) (v).rbegin(), (v).rend() using namespace std; using lint = long long; using ld = long double; int INF = 2000000000; lint LINF = 1000000000000000000; int main() { int n, m; cin >> n >> m; vector v(n); rep(i, n) { v[i] = i; } while (m--) { int a; cin >> a; a--; vector nv; nv.emplace_back(v[a]); rep(i, a) { nv.emplace_back(v[i]); } For(i, a + 1, n) { nv.emplace_back(v[i]); } swap(v, nv); } cout << v[0] + 1 << endl; }