#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + c - '0';
  x *= f;
}
int n, m;
int a[N];
int head[N << 1], cnt;
int L[N << 1], R[N << 1];
int inde[N << 1], tpx[N << 1], tpxu;
vector<int> T1[N << 1], T2[N << 1];
long long ans;
struct Edge {
  int to, next;
} e[N << 2];
void add(int x, int y) {
  inde[y]++;
  e[++cnt] = (Edge){y, head[x]}, head[x] = cnt;
}
int main() {
  memset(L, 0x3f, sizeof(L));
  memset(head, -1, sizeof(head));
  read(n), read(m);
  for (int i = 1; i <= m; i++) {
    read(a[i]);
    T1[a[i] - i + n].push_back(i);
    T2[a[i] + i].push_back(i);
  }
  if (n == 1) return puts("0"), 0;
  for (int i = 1; i <= m; i++) {
    int realpos = a[i] - 1;
    if (!realpos) continue;
    int x = realpos - i + n;
    int pos = upper_bound(T1[x].begin(), T1[x].end(), i) - T1[x].begin();
    if (pos < T1[x].size()) add(i, T1[x][pos]);
    x = realpos + i;
    pos = upper_bound(T2[x].begin(), T2[x].end(), i) - T2[x].begin();
    if (pos < T2[x].size()) add(i, T2[x][pos] + m);
  }
  for (int i = 1; i <= m; i++) {
    int realpos = a[i] + 1;
    if (realpos > n) continue;
    int x = realpos - i + n;
    int pos = upper_bound(T1[x].begin(), T1[x].end(), i) - T1[x].begin();
    if (pos < T1[x].size()) add(i + m, T1[x][pos]);
    x = realpos + i;
    pos = upper_bound(T2[x].begin(), T2[x].end(), i) - T2[x].begin();
    if (pos < T2[x].size()) add(i + m, T2[x][pos] + m);
  }
  queue<int> q;
  for (int i = 1; i <= 2 * m; i++)
    if (!inde[i]) q.push(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    tpx[++tpxu] = u;
    for (int i = head[u]; ~i; i = e[i].next) {
      int v = e[i].to;
      inde[v]--;
      if (!inde[v]) q.push(v);
    }
  }
  for (int i = tpxu; i >= 1; i--) {
    int u = tpx[i];
    for (int i = head[u]; ~i; i = e[i].next) {
      int v = e[i].to;
      if (v <= m)
        R[u] = max(R[u], R[v]);
      else
        L[u] = min(L[u], L[v]);
    }
    if (L[u] > n)
      if (u <= m)
        L[u] = max(a[u] - 1 - (m - u), 1);
      else
        L[u] = max(a[u - m] + 1 - (m - (u - m)), 1);
    if (!R[u])
      if (u <= m)
        R[u] = min(a[u] - 1 + (m - u), n);
      else
        R[u] = min(a[u - m] + 1 + (m - (u - m)), n);
  }
  for (int i = 1; i <= n; i++) {
    int x = i + n;
    int ansl = i, ansr = i;
    if (T1[x].size()) {
      int pos = T1[x][0];
      ansr = min(R[pos] + 1, n);
    } else
      ansr = min(i + m + 1, n);
    x = i;
    if (T2[x].size()) {
      int pos = T2[x][0];
      ansl = max(L[pos + m] - 1, 1);
    } else
      ansl = max(i - m - 1, 1);
    ans += ansr - ansl + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
