#include<bits/stdc++.h>
using namespace std;
int p(int n, int m){ //n P m
  for (int i = n; i = m; i--)
    n *= i;
  return n;
}

int main(){
  int N, M, ans;
  cin >> N >> M;
  vector<int> a(M);
  bool a = true;
  for (int i = 0; i < M; i++){
    cin >> a.at(i);
    if (i != 0){
      if (a.at(i) - a.at(i - 1) == 1)
        a = false;
    }
  }
  if(a = true){
    for (int i = 0; i < M; i++){
      if(i == 0){
        if (a.at(i) % 2 == 0){
          int j; int k = a.at(i) / 2 + 1
          while (a.at(i) == j){
            ans += p(k, j); //k P j
            k++; j += 2;
          }
          ans++;
        }
        else{
          int j = (a.at(i) + 1) / 2; int k = 1
            while(a.at(i) == j){
              ans += p(j,k); //j P k
              j++; k += 2;
            }
        }
        else{
          if ((a.at(i) - a.at(i - 1)) % 2 == 0){
            int j; int k = a.at(i) / 2 + 1
            while ((a.at(i) - a.at(i - 1)) == j){
              ans += p(k, j); //k P j
              k++; j += 2;
            }
            ans++;
          }
          else{
            int j = ((a.at(i) - a.at(i - 1)) + 1) / 2; int k = 1
              while((a.at(i) - a.at(i - 1))== j){
                ans += p(j,k); //j P k
                j++; k += 2;
              } 
          }
        }
      }
    }
  }
  if(a = false)
    ans = 0;
  cout << ans << endl;
}