#include <bits/stdc++.h>
using namespace std;
long long N, M, ans;
int t[100001];
long long l[100001];
long long r[100001];
set<pair<int, int> > sor[200100];
int calc(int x, int y) { return (y - x + M); }
int ker(int x, int y) {
  auto it = sor[x].lower_bound({y, -2});
  if (it == sor[x].end()) return (min(N, (long long)x + 1));
  if ((*it).second != -1) return (*it).second;
  y = (*it).first;
  int help = ker(x - 1, y);
  sor[x].erase(it);
  sor[x].insert({y, help});
  return help;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    cin >> t[i];
    sor[calc(i, t[i])].insert({i, -1});
  }
  for (int i = 1; i <= N; i++) {
    r[i] = ker(M + i, 0);
  }
  for (int i = 0; i < 200100; i++) sor[i].clear();
  for (int i = 1; i <= M; i++) {
    sor[calc(i, N + 1 - t[i])].insert({i, -1});
  }
  for (int i = 1; i <= N; i++) {
    l[i] = N + 1 - ker(M + i, 0);
  }
  if (N != 1) {
    for (int i = 1; i <= N; i++) ans += (r[i] - l[i] + 1);
  }
  cout << ans << '\n';
  return 0;
}
