#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll mod = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  bool ok = true;
  for (int i = 0; i < (m); ++i) {
    cin >> a[i];
    if (i && a[i] - a[i - 1] == 1) {
      ok = false;
    }
  }
  if (!ok) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  int idx = 0;
  for (int i = 0; i <= n - 2; ++i) {
    if (a[idx] == 1) {
      idx++;
      i++;
      continue;
    }
    if (a[idx] == i + 2) {
      i += 2;
      idx++;
    } else {
      if (a[idx] == i + 1) {
        i++;
        idx++;
        continue;
      }
      ans *= 2;
    }
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
