#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[100100];
map<int, long long> m1;
vector<int> g[100100];
map<int, int> g1[100100];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &a[i]);
    g[a[i]].push_back(i);
  }
  if (n == 1) {
    if (m > 0)
      printf("0\n");
    else
      printf("1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    int j1;
    for (int j = 0; j < g[i].size();) {
      int ver = g[i][j];
      int temp = ver + 1;
      int z = j + 1;
      for (z = j + 1; z < g[i].size();) {
        if (g[i][z] == temp) {
          z++;
          temp++;
        } else {
          j1 = z;
          break;
        }
      }
      j1 = z;
      for (z = j; z < j1; z++) {
        g1[i][g[i][z]] = temp;
      }
      j = j1;
    }
  }
  long long ans = 0;
  long long sum = 0;
  long long sum1 = 0;
  for (int i = 1; i <= n; i++) {
    sum++;
    m1[-sum]++;
    sum1++;
    for (int j = 0; j < g[i].size(); j++) {
      int cnt = m1[g[i][j] - sum];
      m1[g[i][j] - sum] = 0;
      int time = g1[i][g[i][j]];
      m1[time - sum] += cnt;
    }
    sum1 -= m1[m + 2 - sum];
    m1[m + 2 - sum] = 0;
    ans += sum1;
  }
  m1.clear();
  sum = 0;
  sum1 = 0;
  for (int i = n; i >= 1; i--) {
    sum++;
    m1[-sum]++;
    sum1++;
    for (int j = 0; j < g[i].size(); j++) {
      int cnt = m1[g[i][j] - sum];
      m1[g[i][j] - sum] = 0;
      int time = g1[i][g[i][j]];
      m1[time - sum] += cnt;
    }
    sum1 -= m1[m + 2 - sum];
    m1[m + 2 - sum] = 0;
    ans += sum1;
  }
  ans -= n;
  printf("%lld", ans);
  return 0;
}
