#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll P = 1000000007;
  ll N, M;
  cin >> N >> M;
  vector<ll> a(M, 0);
  vector<int> check(N + 1, 0);
  for (int i = 0; i < M; ++i) {
    cin >> a[i];
    check[a[i]] = 1;
  }
  ll ans = 1;
  for (int i = 0; i < N; ++i) {
    if (check[i] == 1) continue;
    if (check[i + 1] == 0 && check[i + 2] == 0) {
      ans = (ans * 2) % P;
    } else if (check[i + 1] == 1 && check[i + 2] == 1) {
      cout << 0 << endl;
      exit(0);
    }
  }
  cout << ans << endl;
}
