#include <bits/stdc++.h>
using namespace std;
long long factorial(long long n) {
  int tmp = 1;
  for (long long i = 1; i < n + 1; i++) {
    tmp *= i;
  }
  return tmp;
}
void solve() {
  long long N, M;
  cin >> N >> M;
  vector<long long> a(M);
  for (long long i = 0; i < M; i++) cin >> a.at(i);
  bool finish = false;
  for (long long i = 0; i < M - 1; i++) {
    if (a.at(i) + 1 == a.at(i + 1)) {
      finish = true;
      break;
    }
  }
  if (finish) {
    cout << 0 << endl;
    ;
  } else {
    long long s = 0;
    bool skip = false;
    long long ans = 1;
    int m = 0;
    for (long long i = 0; i < N; i++) {
      if (skip) {
        skip = false;
        s = 0;
        continue;
      }
      if (m == M) {
        s += 1;
      } else if (i + 1 == a.at(m)) {
        m += 1;
        skip = true;
        if (s <= 1) {
          ans *= 1;
          continue;
        } else {
          long long comb = 1;
          long long num = s / 2;
          for (long long k = num; k > 0; k--) {
            long long n = s - k;
            comb += factorial(n) / (factorial(k) * factorial(n - k));
          }
          ans *= comb;
        }
      } else {
        s += 1;
      }
    }
    if (s >= 2) {
      long long comb = 1;
      long long num = s / 2;
      for (long long k = num; k > 0; k--) {
        long long n = s - k;
        comb += factorial(n) / (factorial(k) * factorial(n - k));
      }
      ans *= comb;
    }
    cout << ans % 1000000007 << endl;
    ;
  }
}
int main() {
  solve();
  return 0;
}
