#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long factorial(long long n) {
  if (n == 0) return 1;
  return n * factorial(n - 1);
}
long long combination(long long n, long long r) {
  if (r == 1) return 1;
  return factorial(n) / factorial(r) / factorial(n - r);
}
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> 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 << endl;
      return 0;
    }
  }
  long long ans = 1;
  long long cur = 0;
  for (long long broken : a) {
    long long partial_ans = 0;
    long long res = broken - cur - 1;
    for (int i = 0; 2 * i <= res; i++) {
      partial_ans += combination(res, i);
    }
    cur = broken + 1;
    ans *= partial_ans;
  }
  long long res = N - cur;
  long long partial_ans = 0;
  for (int i = 0; 2 * i <= res; i++) {
    partial_ans += combination(res, i);
  }
  ans *= partial_ans;
  cout << ans % MOD << endl;
  return 0;
}
