#include <bits/stdc++.h>
using ll = long long;
using namespace std;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  for (auto &i : a) {
    cin >> i;
  }
  for (int i = 0; i < M - 1; i++) {
    if (a[i] + 1 == a[i + 1]) {
      std::cout << 0 << '\n';
      return 0;
    }
  }
  ll sum = 1;
  for (int i = 2; i < N + 1; i++) {
    if (binary_search(a.begin(), a.end(), i - 1) ||
        binary_search(a.begin(), a.end(), i - 2) ||
        binary_search(a.begin(), a.end(), i)) {
      continue;
    } else {
      sum *= 2;
      sum %= 1000000007;
    }
  }
  std::cout << sum << '\n';
  return 0;
}
