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