func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   int gi() {     int x = 0, o = 1;     char ch = getchar();     while (!isdigit(ch) && ch !=  - ) ch = getchar();     if (ch ==  - ) o = -1, ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x * o;   }   int n, m, a[N], mx[N], mn[N];   map<pair<int, int>, int> f;   map<int, int> lst;   vector<pair<int, int> > key;   set<pair<int, int> > ban;   void work(int *mx) {     f.clear();     lst.clear();     key.clear();     ban.clear();     for (int i = 1; i <= n; i++) key.push_back(make_pair(0, i));     for (int i = 1; i <= m; i++)       if (a[i] > 1) {         key.push_back(make_pair(i, a[i] - 1));         ban.insert(make_pair(i, a[i]));       }     for (int i = 1; i <= m + 1; i++) {       key.push_back(make_pair(i, n));       ban.insert(make_pair(i, n + 1));     }     sort(key.begin(), key.end());     reverse(key.begin(), key.end());     for (auto t : key) {       if (ban.find(make_pair(t.first, t.second + 1)) != ban.end())         lst[t.first - t.second - 1] = t.first;       if (ban.find(make_pair(t.first, t.second)) != ban.end()) continue;       if (lst.count(t.first - t.second)) {         int x = lst[t.first - t.second], y = x - t.first + t.second;         if (ban.find(make_pair(x, y - 1)) != ban.end())           f[t] = f[make_pair(x, y - 2)];         else           f[t] = f[make_pair(x, y - 1)];       } else         f[t] = t.second + m + 1 - t.first;     }     for (int i = 1; i <= n; i++) mx[i] = f[make_pair(0, i)];   }   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++) a[i] = gi();     if (n == 1) return cout << 0, 0;     work(mx);     for (int i = 1; i <= m; i++) a[i] = n - a[i] + 1;     work(mn);     reverse(mn + 1, mn + n + 1);     for (int i = 1; i <= n; i++) mn[i] = n - mn[i] + 1;     long long ans = 0;     for (int i = 1; i <= n; i++) ans += mx[i] - mn[i] + 1;     cout << ans;     return 0;   }   