#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  int n, m;
  cout << mod << endl;
  scanf("%d %d", &n, &m);
  int broken[n + 5], x;
  memset(broken, 0, sizeof broken);
  while (m--) {
    scanf("%d", &x);
    broken[x] = 1;
  }
  broken[n + 1] = broken[n + 2] = 1;
  long long ans = 1;
  int mult;
  for (int i = 0; i < n; i++) {
    if (broken[i]) continue;
    mult = 2;
    if (broken[i + 1]) mult--;
    if (broken[i + 2]) mult--;
    if (mult == 0) {
      printf("0\n");
      return 0;
    }
    ans = ((ans % mod) * (mult % mod)) % mod;
  }
  printf("%I64d\n", ans);
  return 0;
}
