#include <bits/stdc++.h>
using namespace std;
long long gcd(long long m, long long n);
long long lcm(long long m, long long n);
int main(void) {
  int n, m;
  cin >> n >> m;
  long long ans = 1;
  vector<int> v;
  for (int i = 0; i <= n; i++) {
    if (i == n || i == n - 1) {
      v.push_back(1);
      continue;
    }
    v.push_back(2);
  }
  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    v[tmp] = 1;
    v[tmp - 1] = v[tmp - 1] - 1;
    if (tmp != 1) {
      v[tmp - 2] = v[tmp - 2] - 1;
    }
  }
  long long t = 1e9 + 7;
  for (int i : v) {
    ans = ans * i;
    ans %= t;
  }
  cout << ans << endl;
  return 0;
}
long long gcd(long long m, long long n) {
  long long temp;
  while (m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}
long long lcm(long long m, long long n) { return m * n / gcd(m, n); }
