#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
template <class T>
inline bool MX(T &l, const T &r) {
  return l < r ? l = r, 1 : 0;
}
template <class T>
inline bool MN(T &l, const T &r) {
  return l > r ? l = r, 1 : 0;
}
const ll MOD = 1e9 + 7;
const int nn = 112345;
ll bit[nn + 1];
ll sum(int i) {
  ++i;
  ll s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}
void add(int i, ll x) {
  ++i;
  while (i <= nn) {
    bit[i] += x;
    i += i & -i;
  }
}
void add(int l, int r, ll x) {
  if (l >= r) return;
  add(l, x);
  add(r, -x);
}
int lb(ll v) {
  int l = 0, r = nn;
  if (sum(l) >= v) return 0;
  while (r - l > 1) {
    int m = (l + r) / 2;
    (sum(m) < v ? l : r) = m;
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int(i) = 0; (i) < (m); ++(i)) cin >> a[i], --a[i];
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int(i) = 1; (i) < (n); ++(i)) add(i, 1);
  for (int x : a) {
    add(0, n, 1);
    int l = lb(x);
    int r = lb(x + 1);
    ;
    add(l, r, -1);
  }
  ll re = 0;
  for (int(i) = 0; (i) < (n); ++(i)) re += min(n - 1ll, sum(i) + 1) + 1;
  for (int(i) = 0; (i) < (n); ++(i))
    ;
  fill(bit, bit + nn + 1, 0);
  for (int(i) = 1; (i) < (n); ++(i)) add(i, 1);
  for (int x : a) {
    add(0, n, -1);
    int l = lb(x);
    int r = lb(x + 1);
    add(l, r, 1);
  }
  for (int(i) = 0; (i) < (n); ++(i)) re -= max(0ll, sum(i) - 1);
  for (int(i) = 0; (i) < (n); ++(i))
    ;
  cout << re << endl;
  return 0;
}
