#include <bits/stdc++.h>
using namespace std;
const int Nmax = 1e5 + 112;
int n, m, a[Nmax];
vector<int> ball[2 * Nmax];
long long ans;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  if (n == 1) {
    if (m == 0)
      cout << 1;
    else
      cout << 0;
    return 0;
  }
  for (int i = (int)1; i <= (int)n; ++i) {
    ball[i].push_back(i);
  }
  for (int i = (int)1; i <= (int)m; ++i) {
    cin >> a[i];
    int pos = a[i] + i;
    if (ball[pos].size() > ball[pos + 1].size()) swap(ball[pos], ball[pos + 1]);
    while (!ball[pos].empty()) {
      ball[pos + 1].push_back(ball[pos].back());
      ball[pos].pop_back();
    }
  }
  for (int i = (int)1; i <= (int)n + m + 1; ++i) {
    for (int j = (int)0; j < (int)ball[i].size(); ++j) {
      ans = ans + ball[i][j] - max(1, i - m - 1) + 1;
    }
  }
  for (int i = (int)1; i <= (int)n + m + 1; ++i) ball[i].clear();
  for (int i = (int)1; i <= (int)n; ++i) {
    ball[i + m].push_back(i);
  }
  for (int i = (int)1; i <= (int)m; ++i) {
    int pos = a[i] - i + m;
    if (ball[pos].size() > ball[pos - 1].size()) swap(ball[pos], ball[pos - 1]);
    while (!ball[pos].empty()) {
      ball[pos - 1].push_back(ball[pos].back());
      ball[pos].pop_back();
    }
  }
  for (int i = (int)1; i <= (int)n + m + 1; ++i) {
    for (int j = (int)0; j < (int)ball[i].size(); ++j) {
      ans = ans + min(n + m, i + m + 1) - m - ball[i][j];
    }
  }
  cout << ans;
}
