#include <bits/stdc++.h>
using namespace std;
unsigned long long C(unsigned long long N, unsigned long long R) {
  unsigned long long ans = 1;
  for (unsigned long long i = N; i > N - R; --i) {
    ans = ans * i;
  }
  for (unsigned long long i = 1; i < R + 1; ++i) {
    ans = ans / i;
  }
  return ans;
}
int main() {
  unsigned long long N, M;
  cin >> N >> M;
  vector<unsigned long long> a(M);
  vector<unsigned long long> step;
  unsigned long long pre_a = -1;
  unsigned long long check_a;
  for (unsigned long long i = 0; i < M; i++) {
    cin >> check_a;
    if ((check_a - pre_a) == 1) {
      cout << 0;
      return 0;
    }
    pre_a = check_a;
    a[i] = check_a;
  }
  unsigned long long j = 0;
  for (unsigned long long i = 0; i < N; i++) {
    if ((j < M) && (a[j] == i)) {
      if (i > 0) step.pop_back();
      step.push_back(2);
      j++;
    } else {
      step.push_back(1);
    }
  }
  unsigned long long ans = 1;
  unsigned long long One_num = 0;
  for (unsigned long long i = 0; i < step.size(); i++) {
    if (step[i] == 1) {
      One_num++;
    } else if (step[i] == 2) {
      unsigned long long pattern = 0;
      for (unsigned long long p = 0; p <= One_num / 2; p++) {
        pattern += C(One_num - p, p);
      }
      ans *= pattern;
      One_num = pattern = 0;
    }
  }
  if (One_num > 0) {
    unsigned long long pattern = 0;
    for (unsigned long long p = 0; p <= One_num / 2; p++) {
      pattern += C(One_num - p, p);
    }
    ans *= pattern;
  }
  cout << ans % 1000000007;
}
