func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m;   int ara[100005];   int pri[100005];   vector<int> jog[2 * 100005], biyog[2 * 100005];   map<pair<int, int>, int> dp1, dp2;   int cnt1(int x, int y) {     if (y == m + 1) return x;     if (dp1.find({x, y}) != dp1.end()) return dp1[{x, y}];     int val = x - y + 100005;     int idx =         lower_bound(biyog[val].begin(), biyog[val].end(), y) - biyog[val].begin();     if (idx == biyog[val].size()) return dp1[{x, y}] = min(n, x + m + 1 - y);     int j = biyog[val][idx];     assert(j != y);     return dp1[{x, y}] = cnt1(ara[j], pri[j]);   }   int cnt2(int x, int y) {     if (y == m + 1) return x;     if (dp2.find({x, y}) != dp2.end()) return dp2[{x, y}];     int val = x + y;     int idx = lower_bound(jog[val].begin(), jog[val].end(), y) - jog[val].begin();     if (idx == jog[val].size()) return dp2[{x, y}] = max(1, x - m - 1 + y);     int j = jog[val][idx];     assert(j != y);     return dp2[{x, y}] = cnt2(ara[j], pri[j]);   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= m; i++) scanf( %d , ara + i);     if (n == 1) {       printf( 0 n );       return 0;     }     for (int i = 1; i <= m; i++) {       jog[ara[i] + i].push_back(i);       biyog[ara[i] - i + 100005].push_back(i);     }     for (int i = 0; i < 2 * 100005; i++) sort(jog[i].begin(), jog[i].end());     for (int i = 0; i < 2 * 100005; i++) sort(biyog[i].begin(), biyog[i].end());     for (int i = m; i; i--) {       if (ara[i] == ara[i + 1])         pri[i] = pri[i + 1];       else         pri[i] = i + 1;     }     long long ans = 0;     for (int i = 1; i < n; i++) ans += cnt1(i, 0) - i;     for (int i = 2; i <= n; i++) ans += i - cnt2(i, 0);     ans += n;     printf( %lld n , ans);     return 0;   }   