#ifdef LOCAL #include #else #pragma GCC optimize("O3") // #pragma target("arch=skylake-avx512") #include #define debug(...) ((void)0) #endif using namespace std; using ll = long long; using ld = long double; void solve(int) { int N, M; cin >> N >> M; set> s; vector A(N); iota(A.begin(), A.end(), 1); for (int i = 0; i < M; i++) { int S; cin >> S; S--; int x = A[S], y = A[S + 1]; if (x > y) swap(x, y); s.insert({x, y}); swap(A[S], A[S + 1]); } cout << s.size() << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; for (int i = 1; i <= t; i++) { solve(i); } #ifdef LOCAL postprocess(); #endif }