#include <bits/stdc++.h>
using namespace std;
int stroot(int str, int end) {
  int dansu = end - str;
  int roots = 1;
  if (dansu % 2 == 0) {
    for (int j = dansu / 2; j > 0; j--) {
      roots *= j;
      return roots;
    }
  } else {
    roots *= (dansu + 1) / 2;
    for (int i = dansu / 2; i > 0; i--) {
      roots *= i;
      return roots;
    }
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  int a[M];
  for (int i = 0; i < M; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < M; i++) {
    if (a[i] - a[i - 1] == 1) {
      cout << 0;
      exit(0);
    }
  }
  int ans = 1;
  ans *= stroot(0, a[0]) * stroot(a[M - 1], N);
  for (int i = 2; i < M; i++) {
    ans *= stroot(a[i - 1], a[i]);
  }
  ans %= 1000000007;
  cout << ans;
}
