func_code_string: #include <bits/stdc++.h>   using namespace std;   using ii = pair<int, int>;   using vi = vector<int>;   using vvi = vector<vi>;   using vii = vector<ii>;   using vb = vector<bool>;   using ll = long long;   template <typename A, typename B>   istream &operator>>(istream &in, pair<A, B> &p) {     in >> p.first >> p.second;     return in;   }   template <typename T>   istream &operator>>(ifstream &in, vector<T> &v) {     for (int i = 0; i < (int)v.size(); ++i) {       in >> v[i];     }     return in;   }   int main() {     int n, k;     cin >> n >> k;     vector<set<int>> times(n);     for (int i = 0; i < k; ++i) {       int x;       cin >> x;       x--;       times[x].insert(i);     }     int res = 0;     for (int x = 0; x < n; ++x) {       if (times[x].empty()) {         res += 3;         if (x == 0) res--;         if (x == n - 1) res--;       } else {         int t = *times[x].begin();         if (x != n - 1 && times[x + 1].lower_bound(t) == times[x + 1].end())           res++;         if (x != 0 && times[x - 1].lower_bound(t) == times[x - 1].end()) res++;       }     }     cout << res << endl;   }   