#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, m, a[N];
int l[N], r[N], fa[N];
int pos[N << 2], p[N];
int gf(int x) { return fa[x] == x ? x : fa[x] = gf(fa[x]); }
void Solver() {
  memset(p, 0, sizeof(p));
  memset(pos, 0, sizeof(pos));
  for (int i = 1; i <= n; ++i) pos[i + N] = i, fa[i] = i;
  for (int i = 1; i <= m; ++i) {
    if (pos[a[i] - i + N]) {
      int x = pos[a[i] - i + N];
      int y = pos[a[i] - i - 1 + N];
      if (y) {
        fa[x] = y;
      } else {
        pos[a[i] - i - 1 + N] = x;
      }
      pos[a[i] - i + N] = 0;
    }
  }
  for (int i = -max(n, m) * 4; i <= max(n, m) * 4; ++i) {
    p[pos[i - m - 1 + N]] = i;
  }
  for (int i = 1; i <= n; ++i) r[i] = p[gf(i)];
}
void Solvel() {
  memset(p, 0, sizeof(p));
  memset(pos, 0, sizeof(pos));
  for (int i = 1; i <= n; ++i) pos[i + N] = i, fa[i] = i;
  for (int i = 1; i <= m; ++i) {
    if (pos[a[i] + i + N]) {
      int x = pos[a[i] + i + N];
      int y = pos[a[i] + i + 1 + N];
      if (y) {
        fa[x] = y;
      } else {
        pos[a[i] + i + 1 + N] = x;
      }
      pos[a[i] + i + N] = 0;
    }
  }
  for (int i = -max(m, n) * 4; i <= max(n, m) * 4; ++i) {
    p[pos[i + m + 1 + N]] = i;
  }
  for (int i = 1; i <= n; ++i) l[i] = p[gf(i)];
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) cin >> a[i];
  long long ans = 0;
  Solver();
  Solvel();
  for (int i = 1; i <= n; ++i) r[i] = min(r[i], n), l[i] = max(l[i], 1);
  for (int i = 1; i <= n; ++i) ans += r[i] - l[i] + 1;
  if (n == 1)
    cout << 0 << endl;
  else
    cout << ans << endl;
}
