func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   #pragma GCC target( sse2 )   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     std::cerr << name <<   :   << arg1 <<   n ;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     std::cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   long long max(long long a, long long b) { return (a > b) ? a : b; }   long long min(long long a, long long b) { return (a < b) ? a : b; }   void amax(long long& a, long long b) { a = max(a, b) % 1000000007; }   void amin(long long& a, long long b) { a = min(a, b) % 1000000007; }   void inc(long long& a, long long b) { a = (a + b) % 1000000007; }   void dec(long long& a, long long b) { a = (a - b + 1000000007) % 1000000007; }   long long solve() {     long long n, p;     cin >> n >> p;     vector<long long> in(n + 10, 1e9), out(n + 10, 0);     for (long long i = 0; i < p; i++) {       long long x;       cin >> x;       amin(in[x], i + 1);       amax(out[x], i + 1);     }     long long ans = 0;     for (long long i = 1; i < n + 1; i++) {       if (out[i] == 0) {         ans++;       }       long long cur = out[i];       if (in[i] > out[i + 1] && i + 1 <= n) ans++;       if (in[i] > out[i - 1] && i > 1) ans++;     }     cout << ans;     return 0;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       solve();     }   }   