#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const long long LINF = 1e11;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a = vector<int>(m, 0);
  for (int i = 0; i < m; ++i) {
    cin >> a[i];
  }
  long long ans = 1;
  int aIdx = 0;
  for (int i = 0; i < n - 1; ++i) {
    long long route = 2;
    int brokenStep1 = -1;
    int brokenStep2 = -1;
    if (aIdx < a.size()) {
      brokenStep1 = a[aIdx];
    }
    if (aIdx + 1 < a.size()) {
      brokenStep2 = a[aIdx + 1];
    }
    if (i == brokenStep1) {
      aIdx++;
      continue;
    }
    if (i + 1 == brokenStep1) {
      route--;
    }
    if (i + 2 == brokenStep1 || i + 2 == brokenStep2) {
      route--;
    }
    if (route == 0) {
      ans = 0;
      break;
    }
    ans = ans * route % MOD;
  }
  cout << ans << "\n";
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
