#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MAX_MOD 1000000007 #define REP(i,n) for(long long i = 0;i < n;++i) #define LONGINF 1000000000000000000 int hoge[200000] = {}; int main() { int n, m; cin >> n >> m; int now = 1; vector reversing; REP(i, m) { int tmp; cin >> tmp; reversing.push_back(tmp); } reverse(reversing.begin(), reversing.end()); for (int i = 0;i < m;++i) { int tmp = reversing[i]; if (now == 1) { now = tmp; } else if (now < tmp) { now--; } } cout << now << endl; return 0; }